简体   繁体   English

Docpad-如何找出速度慢的原因?

[英]Docpad - how can I find out why it is slow?

I'm migrating my tumblr blog to docpad and have started with this boilerplate: https://github.com/ervwalter/ewalnet-docpad 我正在将自己的tumblr博客迁移到docpad,并已开始使用以下样板: https : //github.com/ervwalter/ewalnet-docpad

Now my problem is that "docpad run" takes 58s to run, and a livereload run takes 23s. 现在我的问题是“ docpad运行”需要58秒才能运行,而livereload运行需要23秒。 I wrote the author of this boilerplate and he says he is having the same, but it doesn't bother him too much. 我写了这个样板的作者,他说他也有相同的意思,但这并不过分。

But I don't want to wait half a minute for every change in a blog post to see how it looks like, so I'm trying to make it faster. 但是,我不想等到博客文章中的每一次更改都花半分钟的时间才能看到它的样子,所以我试图使其更快。 I tried profiling with nodetime but I don't see a drilldown per method or so. 我尝试使用nodetime进行性能分析,但未看到每种方法的深入分析。 My assumption is that the time is lost in the partials, at it sends the whole posts to the partials 我的假设是时间浪费在分词中,它会将整个帖子发送到分词

How can I profile Docpad so I see where the time is lost? 如何配置Docpad,以便了解时间浪费在哪里? I know the question is very broad, but all I found on performance optimizing on DocPad is that you should make Docpad not to parse static files. 我知道问题很广泛,但是我在DocPad上进行性能优化时发现的所有问题是,您应该使Docpad不解析静态文件。

Update the missing link was that I needed to start the CPU profiler on nodetime: 更新缺少的链接是我需要在nodetime上启动CPU profiler

  1. configure nodetime, described here 配置节点时间, 在这里描述
  2. start CPU profiler on nodetime 在nodetime上启动CPU profiler
  3. start docpad: docpad --profile run 启动docpad: docpad --profile run

Unfortunately in my case the output is not much helping. 不幸的是,就我而言,输出没有太大帮助。 The results of my run reveal that 81% of the time is spent in ambi.js , which seems is just a intermediate layer which calls functions. 我的运行结果表明, 81.%的时间都花在了ambi.js ,这似乎只是一个调用函数的中间层。 I could not find out which functions are called, adding console.log(fireMethod.toString()) I only see 我找不到添加了console.log(fireMethod.toString())函数,我只看到了

function () { [native code] }

so I'm not really further. 所以我走的并不远。 How can I find out where the time is actually spent? 我如何找出实际花费的时间? For reference: here is my v8.log 供参考:这是我的v8.log

Also, I'm a bit worried, that docpad almost only relies on modules written by Benjamin Lupton. 另外,我有点担心,该docpad几乎仅依赖于Benjamin Lupton编写的模块。 Why is that so? 为什么?

After an odyssey of about 1 week I came to the conclusion that Docpad is not made for speed, it is made to handle complex sites. 经过大约1周的冒险之旅,我得出的结论是Docpad并不是为了提高速度而设计的,而是为了处理复杂的站点而设计的。 Some facts: 一些事实:

  • even a fresh docpad installation with only twitter bootstrap takes 12s to build 即使只有twitter引导程序的全新docpad安装,也需要12s来构建
  • there are no means to only regenerate the files which source files have changed (dependency tree), it always regenerates everything 没有办法只重新生成源文件已更改的文件(依赖关系树),它总是重新生成所有内容
  • reading threads like this show that speed is not in focus 读线程像这样显示,速度不在焦点

My use case is writing articles for a blog and I have a lot of "change text and see how it looks" loops. 我的用例是为博客撰写文章,并且有很多“更改文本并查看外观”循环。 I have switched to Hexo which is a lot faster: 我改用了Hexo,它快得多了:

  • hexo server starts in 2.5 seconds. hexo server在2.5秒内启动。 With livereload on, when I change a blog post, the broswer tab reloads the page and shows the new content in about 1s livereload后,当我更改博客文章时,“浏览”标签会重新加载页面并在大约1 livereload显示新内容
  • generating all files afresh with hexo clean and hexo generate takes only 5s. hexo clean重新生成所有文件, hexo generate只需要5s。

This is the same setup (with less , coffeescript , etc.) I had for DocPad where DocPad needed 38s to run. 这是我为DocPad使用的相同设置(具有lesscoffeescript等),其中DocPad需要38s才能运行。

Additionally to speed hexo gave me 另外为了加速hexo给了我

  • themes : hexo nicely separates between the theme and the content (DocPad mingles the two). 主题 :十六进制很好地将主题和内容分开(DocPad将两者混合在一起)。 Currently there are about 30 hexo themes to choose from 目前,大约有30种十六进制主题可供选择
  • implementation of read more : in hexo <! --more --> 阅读更多内容 :hexo <! --more --> <! --more --> is supported out of the box <! --more -->开箱即用
  • deployment to github pages is out of the box 部署到github页面是开箱即用的
  • architecture was a lot easier for me to understand, writing widgets is a bliss, the documentation also looks nicer 架构对我来说很容易理解,编写小部件是一种幸福,文档也看起来更好

Overall, it looks like hexo is suited better for blogs, whereas docpad is better suited for more complex sites. 总体而言,看起来hexo更适合博客,而docpad更适合更复杂的网站。 Hexo looks like it's really taking off, getting about 30 stars on github per week, whereas docpad is only getting about 10 stars per week. Hexo看起来确实很不错,每周在github上获得30颗星,而docpad每周仅获得10颗星。

you can use meta 你可以使用元

standalone: true 独立:true

while you work on a file. 在处理文件时。 This meta will regenerate only this file if update it. 如果更新此文件,则此meta仅会重新生成该文件。 Remove the meta after you finish. 完成后删除元。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM