const{createApp}=Vue const{createVuetify,useGoTo,useDisplay}=Vuetify var data={alert:{show:false,color:'success',text:'',timeout:0,},theme:{dark:false,},nav:{showDrawer:false,showTOC:true,tocPanel:0,tab:'account',post:{discussionId:5342,currentPage:1,targetPage:1,total:26,anchor:0,goToOptions:{container:null,duration:0,easing:'easeInOutCubic',offset:-100,},worker:null,task:[],active:[],apiLock:[],originLike:new Map([]),},related:{block:1,}},search:{width:80,text:null,loading:false,},tags:[{id:14,url:'/t/3b3b75196a045c7664770d0c113c',name:'Linux',color:'#66BB6A',icon:'mdi-linux',},],posts:[{id:61448,num:0,uid:2263,content:'\u003Cp\u003E我用两台机器,一台 5600X 一台 7950X 。5600X 那台装的是 Ubuntu 24.04 ,7950X 那台装的是 Windows 10 。两个系统都已经更新到最新补丁,已经尽可能清空后台程序,且内存存储非常富裕。\u003C/p\u003E\u003Cp\u003E对公司项目使用命令行工具构建出 release 版本的 APK 并且计时。结果测速发现 7950X 构建花了 7 分 8 秒,5600X 花了 5 分 12 秒。是的你没看错,测了三次都差不多这结果。更离谱的是 5600X 我甚至还把项目文件放在机械硬盘上的,没想到还是被碾压了。\u003C/p\u003E\u003Cp\u003E公司项目也没啥特别的:AGP 8.9 代码规模也就 6w 行左右 过八成 j**a+不足两成 kotlin ,没有 native 代码,就这个样子。构建任务:构建一个大的 app 模块的 3 个 variant (全 j**a )和两个小的 app 模块(全 kotlin ),总共 5 个 APK 文件。这三个模块除了共享了定义数据协议结构的库以外基本独立。测试之前已经预先构建过,用于把依赖下载完整,所以不存在网络波动导致的时间差异。\u003C/p\u003E\u003Cp\u003E原本以为 7950X 的构建速度上理应碾压 5600X 的,就算系统不同,也不应该有这么大的差距。实在想不出为什么会有这样的结果。在 Windows 上我还特意用了Microsoft Build of OpenJDK 21的。\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-17 23:03:05',updatedAt:'2025-03-20 11:32:09',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61449,num:1,uid:3811,content:'Windows 试试关闭任何杀毒或防护监控软件。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-17 23:09:38',updatedAt:'2025-03-20 11:32:09',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61450,num:2,uid:531,content:'把步骤用时都打印出来啊,我这里 debug 版本都差不多。\u003Cbr\u003E\u003Cbr\u003Erelease 的话,很多 CPU 时间都花在了 assets 压缩上面,也许你的 5600X 对压缩算法有特别优化。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-17 23:10:05',updatedAt:'2025-03-20 11:32:09',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61451,num:3,uid:791,content:'windows 启动进程速度天然会慢很多,安卓构建需要开一堆进程,这一点就会消耗大量时间了',ipRegion:'',updatedByUid:0,createdAt:'2025-03-17 23:32:53',updatedAt:'2025-03-20 11:32:09',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61452,num:4,uid:1031,content:'盲猜文件系统系统,盲猜是由于安全软件(特别是 Windows Defender )引起的',ipRegion:'',updatedByUid:0,createdAt:'2025-03-17 23:33:33',updatedAt:'2025-03-20 11:32:09',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61453,num:5,uid:533,content:'Windows 开 dev drive 扔进去再试',ipRegion:'',updatedByUid:0,createdAt:'2025-03-17 23:54:59',updatedAt:'2025-03-20 11:32:09',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61454,num:6,uid:2263,content:'用 Defender Control 关了 WD 之后,7950X 的时间缩短到了 5 分 51 秒,效果显著但和 5600X 仍有差距。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 00:04:04',updatedAt:'2025-03-20 11:32:09',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61455,num:7,uid:5032,content:'你在 windows 上用 wsl 也会更快',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 00:15:21',updatedAt:'2025-03-20 11:32:09',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61456,num:8,uid:2263,content:'姑且用 --profile 再跑了一次。\u003Cbr\u003E这东西好像坏了,点 Task Execution 看不到每个任务的执行时间,也可能是我没是经过 Android Studio 的,只用命令行工具导致的行为变动。\u003Cbr\u003E\u003Cbr\u003E但发现了个有意思的现象:全 j**a 的大 app 模块构建花了 3 分钟以上,7950X 也不过多了十秒钟构建时间;而时间差距基本全集中在了那两个全 kotlin (可能也不是全 Kotlin ,至少依赖的协议库用 j**a 的)的小 app 模块构建任务上。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 00:17:33',updatedAt:'2025-03-20 11:32:09',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61457,num:9,uid:1287,content:'盲猜是杀毒软件,windows 11 还专门为这个做了个 dev drive, 相当于默认整盘白名单,可以用那个试下。如果还有差距,那就是系统优化方向差异了,linux 大部分优化是注重吞吐量,牺牲延迟,windows 相反,所以有些重量级场景,比如编译大项目,就会慢。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 06:04:52',updatedAt:'2025-03-20 11:32:09',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61458,num:10,uid:1287,content:'还有个可能的是处理器问题,5600 的话是单 ccx, l3 的命中率可能会比多 ccx 的高,假如 j**a 编译比较吃这个,那就有可能 7950x 会慢。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 06:12:52',updatedAt:'2025-03-20 11:32:09',mentionNum:0,mentionedBy:[17,],mentionUsers:[],likeUsers:[],},{id:61459,num:11,uid:4112,content:'不用怀疑,NTFS 的性能确实不如 ext4 ,但是影响整体编译速度差距也只是在 20%,过高按照这个设置一下, https://stackoverflow.com/questions/6916011/how-do-i-get-windows-to-go-as-fast-as-linux-for-compiling-c',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 06:38:43',updatedAt:'2025-03-20 11:32:09',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61460,num:12,uid:6646,content:'之前电脑安装黑苹果,同样的配置,黑苹果打包同一个项目速度是 win10 快很多,没测试过 Ubuntu',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 09:14:07',updatedAt:'2025-03-20 11:32:10',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61461,num:13,uid:826,content:'傻 x Defender',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 09:17:57',updatedAt:'2025-03-20 11:32:10',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61462,num:14,uid:12089,content:'MS: ./gradlew.bat build --scan',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 09:56:24',updatedAt:'2025-03-20 11:32:10',mentionNum:0,mentionedBy:[15,],mentionUsers:[],likeUsers:[],},{id:61463,num:15,uid:12089,content:'#14 Linux: ./gradlew build --scan ,看下耗时对比。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 09:56:47',updatedAt:'2025-03-20 11:32:10',mentionNum:14,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61464,num:16,uid:12090,content:'遇到过,同一台电脑上 wsl 编译比 win11 快。同样百思不得其姐',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 11:04:36',updatedAt:'2025-03-20 11:32:10',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61465,num:17,uid:2263,content:'#10 这个原因挺新鲜的。\u003Cbr\u003E\u003Cbr\u003E#11 感谢,步骤挺多,以后再看看。\u003Cbr\u003E\u003Cbr\u003E#12\u003Cbr\u003E#16\u003Cbr\u003E吼,看起来确实不是个例。\u003Cbr\u003E\u003Cbr\u003E#14 #15 --scan 上传的信息会暴露一些隐私还没法改,之后我自己看看吧。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 12:58:53',updatedAt:'2025-03-20 11:32:10',mentionNum:10,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61466,num:18,uid:2915,content:'很多东西在 Linux 上跑就是比在 Windows 上跑要快很多,文件系统,内核调用等等原因,Linux 内核本身也为大吞吐量而优化,其他的都是为顺畅优化,(大吞吐量:30s 完成但是报告进度可能会卡,顺畅:每秒都准确报告进度但是 60s 才能完成),顺便也比在 MacOS 上跑快(因为硬件不同有点虚空论武)',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 13:27:58',updatedAt:'2025-03-20 11:32:10',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:61467,num:19,uid:6646,content:'要对比也可以,一个超大硬盘,电脑上面同时安装 Ubuntu ,黑苹果,win ,编译同一个项目',ipRegion:'',updatedByUid:0,createdAt:'2025-03-18 15:26:38',updatedAt:'2025-03-20 11:32:10',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[2915,{uid:2915,url:'/u/123b63176a045c75696b536f1d253215',avatar:'/a/123b63176a045c75696b536f1d253215',username:'xausky🤖',}],[533,{uid:533,url:'/u/113159026a045c776569556f13392114',avatar:'/a/113159026a045c776569556f13392114',username:'YsHaNg🤖',}],[3811,{uid:3811,url:'/u/3c1c58196a045c74686b576f46311c11',avatar:'/a/3c1c58196a045c74686b576f46311c11',username:'heiher🤖',}],[4112,{uid:4112,url:'/u/29234b186a045c73616b546f073a2900',avatar:'/a/29234b186a045c73616b546f073a2900',username:'flynaj🤖',}],[12090,{uid:12090,url:'/u/6b0d713e6a045d756063566f381c1d0e',avatar:'/a/6b0d713e6a045d756063566f381c1d0e',username:'gaifanking🤖',}],[5032,{uid:5032,url:'/u/091f703c6a045c726069546f0d113870',avatar:'/a/091f703c6a045c726069546f0d113870',username:'**artruid🤖',}],[791,{uid:791,url:'/u/630d48066a045c776763576f45513d1e',avatar:'/a/630d48066a045c776763576f45513d1e',username:'codehz🤖',}],[531,{uid:531,url:'/u/227a02176a045c776569576f395f060f',avatar:'/a/227a02176a045c776569576f395f060f',username:'tool2dx🤖',}],[2263,{uid:2263,url:'/u/102a5c226a045c75626c556f001c610d',avatar:'/a/102a5c226a045c75626c556f001c610d',username:'HojiOShi🤖',}],[12089,{uid:12089,url:'/u/281a01176a045d7560625f6f1a506575',avatar:'/a/281a01176a045d7560625f6f1a506575',username:'ByePrd🤖',}],[826,{uid:826,url:'/u/080d54286a045c776868506f20181a0e',avatar:'/a/080d54286a045c776868506f20181a0e',username:'xdeng🤖',}],[6646,{uid:6646,url:'/u/2d3d01146a045c71666e506f3f00642a',avatar:'/a/2d3d01146a045c71666e506f3f00642a',username:'debuggeeker🤖',}],[1031,{uid:1031,url:'/u/3c2f021a6a045c766069576f4f392208',avatar:'/a/3c2f021a6a045c766069576f4f392208',username:'liyafe1997🤖',}],[1287,{uid:1287,url:'/u/103e5d226a045c766262516f2e253977',avatar:'/a/103e5d226a045c766262516f2e253977',username:'mayli🤖',}],]),related:[{title:'有给 m2 mini 装 Linux 的吗',url:'/d/1c254b5b6a045c77606a56774e5f676a0e2d6318',},{title:'问个小白问题,debian删除软件包释放的空间变少了怎么回事',url:'/d/137c68346a045c77606a56774f5f636a39241419',},{title:'大家一般都在Linux上用哪个tun2socks项目?',url:'/d/190e76396a045c77606a5677415b616a5e20661d',},{title:'Linux 输入法推荐',url:'/d/322778026a045c77606a56774458646a05772922',},{title:'Ubuntu apt upgrade 升级逻辑是什么?',url:'/d/007f510e6a045c77606a567745506a6a02110514',},{title:'大家一般给小鸡分配多大的Swap?',url:'/d/09135f0c6a045c77606a567645506a6a081b2137',},{title:'现在入行 Linux 运维还有希望吗?',url:'/d/682d7f016a045c77606a5671415e6a6a0407241b',},{title:'Android 15 现在也能用官方的 Linux 了',url:'/d/2d0b44556a045c77606a56734e5f606a061a606a',},],} const App={setup(){const goTo=useGoTo() const{mdAndUp}=useDisplay() return{goTo,mdAndUp}},data(){return data;},mounted(){const themeDark=localStorage.getItem("themeDark") if(themeDark!==null){this.theme.dark=JSON.parse(themeDark)} if(this.nav.post.total>(this.nav.post.currentPage-1)*100+20){let moreLen=100 if(this.nav.post.total({id:null,num:(this.nav.post.currentPage-1)*100+v,uid:null,content:null,ipRegion:null,updatedByUid:null,createdAt:null,updatedAt:null,mentionNum:null,mentionedBy:null,mentionUsers:null,likeUsers:null,})) this.posts.push(...morePosts.slice(20))} this.workerStart() const hash=window.location.hash const match=hash.match(/#(\d+)/) if(match){const n=parseInt(match[1],10) if(n>=(this.nav.post.currentPage-1)*100&&n{this.jumpTo(n)})}} this.$nextTick(()=>{this.addHeadingIds() tocbot.init({tocSelector:'.toc',contentSelector:'#post-content-0',headingSelector:'h2, h3, h4',headingsOffset:100,scrollSmoothOffset:-100,scrollSmooth:true,collapseDepth:6,onClick:function(e){setTimeout(()=>{history.replaceState(null,'',window.location.pathname+window.location.search)},0)},}) tocbot.refresh()});},beforeUnmount(){this.workerStop() if(this.quill){this.quill.destroy() this.quill=null}},computed:{dposts(){return this.posts.slice(20);},},created(){},methods:{successAlert(msg){this.alert={show:true,color:'success',text:msg,timeout:1500,}},failureAlert(msg){this.alert={show:true,color:'error',text:msg,timeout:5000,}},flipThemeDark(){this.theme.dark=!this.theme.dark localStorage.setItem("themeDark",JSON.stringify(this.theme.dark))},toSearch(){if(!this.search.text){this.failureAlert('搜索词不能为空') return} let keywords=this.search.text.trim() if(keywords.length<1){this.failureAlert('搜索词不能为空') return} if(keywords.length>100){this.failureAlert('搜索词过长') return} this.doSearch(keywords)},toReg(){window.location.href="/reg"},toLogin(){window.location.href="/login"},toPage(){let url=window.location.href url=url.replace(/(\/\d+)?(#[0-9]+)?$/,this.nav.post.targetPage>1?`/${this.nav.post.targetPage}`:'') window.location.href=url},toLoadRelated({done}){if(this.my&&this.my.uid){this.apiLoadRelated({done})}else{done('ok')}},workerStart(){this.nav.post.worker=setInterval(()=>{this.workerLoad()},500);},workerStop(){if(this.nav.post.worker){clearInterval(this.nav.post.worker);this.nav.post.worker=null;}},async jumpTo(num){const page=Math.floor(num/100)+1 const i=num-(page-1)*100 if(page===this.nav.post.currentPage){this.goTo("#post-"+num,this.nav.post.goToOptions) if(!this.posts[i].id){const block=Math.floor(num/20)+1 this.nav.post.apiLock[block]=true await this.apiLoadPosts(block) this.$nextTick(()=>{this.goTo("#post-"+num,this.nav.post.goToOptions)})}}else{let url=window.location.href url=url.replace(/(\/\d+)?(#[0-9]+)?$/,page>1?`/${page}`:'') url=url+"#"+num window.location.href=url}},postIntersect(num){return(isIntersecting,entries,observer)=>{if(isIntersecting){this.nav.post.task.push(num) this.nav.post.active.push(num) this.nav.post.active=this.nav.post.active.filter(item=>Math.abs(item-num)<=5) this.nav.post.active.sort((a,b)=>a-b)}else{this.nav.post.active=this.nav.post.active.filter(item=>item!==num)} if(this.nav.post.active[0]){this.nav.post.anchor=this.nav.post.active[0]}else{this.nav.post.anchor=0}}},async apiLoadPosts(block){try{const response=await axios.post('/fapi/v1/post/block/'+block,{discussionId:this.nav.post.discussionId,}) if(response.data.code===0){response.data.data.posts.forEach(post=>{const i=post.num%100 Object.assign(this.posts[i],post)}) response.data.data.users.forEach(user=>{this.usersMap.set(user.uid,user)})}else{this.failureAlert('回帖数据加载失败: '+response.data.msg)}}catch(error){this.failureAlert('回帖数据加载失败: '+error)} this.nav.post.apiLock[block]=false},workerLoad(){while(this.nav.post.task.length){const num=this.nav.post.task.pop() const i=num-(this.nav.post.currentPage-1)*100 if(!this.posts[i].id){const block=Math.floor(num/20)+1 if(!this.nav.post.apiLock[block]){this.nav.post.apiLock[block]=true this.apiLoadPosts(block)}}}},getTimeInfo(t){if(!t){return ""} const now=new Date();const then=new Date(t);const diff=now-then;const minute=60*1000;const hour=minute*60;const day=hour*24;const month=day*30;const year=month*12;if(diffpost.num===num) if(!post){return "#"+num} const uid=post.uid const username=this.usersMap.get(uid)?.username if(!username){return "#"+num} return username},getUsernameByPostId(id){const post=this.posts.find(post=>post.id===id) if(!post){return "#"+this.getPostNumByPostId(id)} const uid=post.uid const username=this.usersMap.get(uid).username if(!username){return "#"+this.getPostNumByPostId(id)} return username},getPostNumByPostId(id){const post=this.posts.find(post=>post.id===id) return post.num},getPostById(id){const post=this.posts.find(post=>post.id===id) return post},getPostByNum(num){const post=this.posts.find(post=>post.num===num) return post},getAvatarByUid(uid){const avatar=this.usersMap.get(uid)?.avatar if(!avatar){return this.getRandomAvatar()} return avatar},getAvatarByPostNum(num){const post=this.posts.find(post=>post.num===num) if(!post){return this.getRandomAvatar()} const uid=post.uid return this.getAvatarByUid(uid)},getRandomAvatar(){const num=Math.floor(Math.random()*100) return "https://randomuser.me/api/portraits/men/"+num+".jpg"},getUrlByUid(uid){const url=this.usersMap.get(uid)?.url if(!url){return ""} return url},getTextByPostNum(num){const post=this.posts.find(post=>post.num===num) if(!post||!post.content){return '点击跳转到#'+num+'查看'} const parser=new DOMParser() const doc=parser.parseFromString(post.content,'text/html') const text=doc.body.textContent||'' return text.slice(0,100)},addHeadingIds(){const content=document.getElementById('post-content-0') if(!content){this.nav.showTOC=false return} const headings=content.querySelectorAll('h2, h3, h4') headings.forEach((heading,index)=>{if(!heading.id){heading.id=`toc-nav-${index}`}}) if(headings.length==0){this.nav.showTOC=false}},async doSearch(keywords){this.search.loading=true try{const response=await axios.post('/fapi/v1/search',{keywords:keywords,}) if(response.data.code===0){if(response.data.data.hash&&response.data.data.hash.length===32){window.location.href="/s/"+response.data.data.hash}else{this.failureAlert('搜索失败: 搜索服务异常')}}else{this.failureAlert('搜索失败: '+response.data.msg)}}catch(error){this.failureAlert('搜索失败: '+error)} this.search.loading=false},debounce(fn,delay){let timer=null return function(...args){if(timer)clearTimeout(timer) timer=setTimeout(()=>{fn.apply(this,args)},delay);};},},watch:{'nav.post.targetPage':{handler:async function(newV,oldV){this.toPage()},immediate:false},},} const vuetify=createVuetify({defaults:{global:{ripple:true,},},}) const app=createApp(App) app.use(vuetify).mount("#app")