2

I'm using nanoc to generate documentation for my project. I have several files (~50) and layouts already created but currently I'm working on a single file. Strange thing is that it compiles this one file in less than second and than working on something what takes more than 20 seconds!

Loading site data…
Compiling site…
      update  [0.71s]  output/docs/js/getData/index.html

Site compiled in 22.96s.

When I abort the process after:

      update  [0.71s]  output/docs/js/getData/index.html

line with CTRL+C and the nanoc view my file is compiled well. Do you have any idea how to speed up the process? What nanoc is doing for 20 seconds?

keepkimi
  • 373
  • 3
  • 12

1 Answers1

5

By default, nanoc only shows files that are created, updated or deleted. Files that are recompiled but turn out to be identical will not be shown. If you pass --verbose to nanoc compile, you will see which files are compiled but identical.

So, those 20 seconds where nanoc seems to be doing nothing are likely 20 seconds where nanoc is busy recompiling, but finding that the compiled files are the same, so they’re not shown.

Items will be recompiled unless nanoc can be sure that they will remain identical. Occasionally, nanoc cannot know with certainty that a file will be identical when recompiled, so in this case the item will be recompiled anyway.

23 seconds to compile a site with 50 pages seems slow though. It helps to pick fast filters (e.g., RDiscount for Markdown, pygments.rb for syntax coloring). If you can, run nanoc through a Ruby profiler (e.g., perftools.rb) to find out where the slowness is coming from.

Denis Defreyne
  • 2,213
  • 15
  • 18
  • You were right. I passed --verbose and I see where's the problem. In table that shown after compiling I see that total time of colorize_syntax is 22.33s. I use pygmentize. Which one will be faster for colorizing HTML and JS snipets? – keepkimi Jan 22 '13 at 11:24
  • Pygmentize is awfully slow. A direct replacement is [pygments.rb](https://github.com/tmm1/pygments.rb), which is a lot faster (already mentioned above). Take a look at [pull request #100 for developer.github.com](https://github.com/github/developer.github.com/pull/100) to get an idea of the speedup! I personally use CodeRay though, works fine as well. Can you give an idea of the speedup you got now? – Denis Defreyne Jan 22 '13 at 14:03
  • 1
    I replaced pygmentize with coderay. 20 seconds vs. less than 1 second :) – keepkimi Jan 22 '13 at 21:54