Skip to content

Instantly share code, notes, and snippets.

@eregon eregon/README.md
Created Oct 11, 2011

Embed
What would you like to do?
Theorical benchmark of `require` time when using Yura Sokolov's patch [Feature #5427]

This is a theoretical benchmark of require time comparing ruby 1.9.4 r33453 original and patched on a 64-bit Linux with a sequential hard disk.

It is theoretical because it is based on requiring a few hundreds empty files from the same folder, which is likely rare.

However, the global result (patched significantly faster than original) should be reflected in a certain measure in real life.

It is showing especially good results, because a file is never required twice, and so the unpatched version always has to check every file loaded.

The patched version could actually be slower when:

  • there are a lot of files loaded
  • the user tries many times to require one of the first files loaded

But I could not confirm this in my benchmarks, and this case should never happen (because the first files loaded are loaded by ruby before running the code).

The benchmark was ran 20 times for each ruby. I also ran a manual benchmark on each ruby and the results are similar, it was just a bit faster on the original than expected.

Making good benchmarks is hard, so please teach me if I made a mistake. However, I'm confident about this one.

And, a big "thank you" to Yura Sokolov for this patch!

P.S.: The same benchmark ran on 1.8.7 can be seen at https://gist.github.com/1279106

{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.02,0.01,0.0,0.0,0.024889747), :run => 0}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.01,0.04,0.0,0.0,0.051353132), :run => 0}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.03,0.04,0.0,0.0,0.075203587), :run => 0}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.05,0.06,0.0,0.0,0.110736431), :run => 0}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.07,0.07,0.0,0.0,0.135817721), :run => 0}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.01,0.03,0.0,0.0,0.033968168), :run => 1}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.02,0.03,0.0,0.0,0.052985032), :run => 1}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.05,0.03,0.0,0.0,0.08302026), :run => 1}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.06,0.05,0.0,0.0,0.106738125), :run => 1}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.08,0.07,0.0,0.0,0.162569813), :run => 1}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.02,0.01,0.0,0.0,0.026038877), :run => 2}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.02,0.04,0.0,0.0,0.050293355), :run => 2}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.04,0.04,0.0,0.0,0.076673574), :run => 2}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.06,0.05,0.0,0.0,0.107592025), :run => 2}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.07,0.06,0.0,0.0,0.130677157), :run => 2}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.02,0.019999999999999997,0.0,0.0,0.047908326), :run => 3}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.03,0.03,0.0,0.0,0.053380376), :run => 3}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.04,0.049999999999999996,0.0,0.0,0.08620212), :run => 3}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.05,0.07,0.0,0.0,0.12561694), :run => 3}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.06,0.07,0.0,0.0,0.138479222), :run => 3}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.02,0.03,0.0,0.0,0.037307764), :run => 4}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.02,0.04,0.0,0.0,0.050545308), :run => 4}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.04,0.04,0.0,0.0,0.078948603), :run => 4}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.060000000000000005,0.04,0.0,0.0,0.10379526), :run => 4}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.08,0.08,0.0,0.0,0.168151829), :run => 4}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.03,0.03,0.0,0.0,0.055570409), :run => 5}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.02,0.03,0.0,0.0,0.053265896), :run => 5}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.04,0.04,0.0,0.0,0.078554358), :run => 5}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.07,0.04,0.0,0.0,0.109224186), :run => 5}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.06,0.07,0.0,0.0,0.136398408), :run => 5}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.02,0.02,0.0,0.0,0.040007207), :run => 6}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.04,0.02,0.0,0.0,0.059454949), :run => 6}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.03,0.05,0.0,0.0,0.077817634), :run => 6}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.05,0.049999999999999996,0.0,0.0,0.099573553), :run => 6}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.06,0.07,0.0,0.0,0.127609623), :run => 6}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.02,0.02,0.0,0.0,0.034991285), :run => 7}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.02,0.04,0.0,0.0,0.052767443), :run => 7}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.05,0.02,0.0,0.0,0.077730901), :run => 7}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.03,0.07,0.0,0.0,0.102187565), :run => 7}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.07,0.08,0.0,0.0,0.147579781), :run => 7}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.01,0.02,0.0,0.0,0.032717121), :run => 8}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.02,0.03,0.0,0.0,0.051853048), :run => 8}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.04,0.04,0.0,0.0,0.08335476), :run => 8}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.05,0.06,0.0,0.0,0.107290752), :run => 8}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.08,0.06,0.0,0.0,0.145539445), :run => 8}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.02,0.01,0.0,0.0,0.028978156), :run => 9}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.01,0.04,0.0,0.0,0.069662467), :run => 9}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.04,0.04,0.0,0.0,0.083329584), :run => 9}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.04,0.07,0.0,0.0,0.115182197), :run => 9}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.08,0.06,0.0,0.0,0.140930462), :run => 9}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.01,0.009999999999999998,0.0,0.0,0.025128338), :run => 10}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.02,0.04,0.0,0.0,0.049319991), :run => 10}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.05,0.03,0.0,0.0,0.076583938), :run => 10}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.049999999999999996,0.06,0.0,0.0,0.109700498), :run => 10}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.07,0.06,0.0,0.0,0.141630806), :run => 10}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.02,0.02,0.0,0.0,0.037423706), :run => 11}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.03,0.02,0.0,0.0,0.054903697), :run => 11}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.04,0.04,0.0,0.0,0.078597129), :run => 11}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.06,0.049999999999999996,0.0,0.0,0.115005398), :run => 11}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.09,0.060000000000000005,0.0,0.0,0.156409521), :run => 11}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.01,0.04,0.0,0.0,0.04829479), :run => 12}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.03,0.03,0.0,0.0,0.049999698), :run => 12}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.04,0.04,0.0,0.0,0.075210562), :run => 12}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.06,0.05,0.0,0.0,0.101453571), :run => 12}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.07,0.05,0.0,0.0,0.125026056), :run => 12}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.0,0.019999999999999997,0.0,0.0,0.028555877), :run => 13}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.02,0.03,0.0,0.0,0.053769214), :run => 13}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.04,0.04,0.0,0.0,0.076640994), :run => 13}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.03,0.08,0.0,0.0,0.101527021), :run => 13}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.05,0.1,0.0,0.0,0.152831613), :run => 13}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.01,0.01,0.0,0.0,0.025120801), :run => 14}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.02,0.03,0.0,0.0,0.048905609), :run => 14}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.04,0.03,0.0,0.0,0.084589013), :run => 14}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.04,0.08,0.0,0.0,0.113976508), :run => 14}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.07,0.06,0.0,0.0,0.131605351), :run => 14}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.0,0.019999999999999997,0.0,0.0,0.02795451), :run => 15}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.02,0.03,0.0,0.0,0.050017146), :run => 15}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.07,0.04,0.0,0.0,0.108294622), :run => 15}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.05,0.05,0.0,0.0,0.100184144), :run => 15}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.09,0.09000000000000001,0.0,0.0,0.177747628), :run => 15}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.0,0.03,0.0,0.0,0.028034659), :run => 16}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.01,0.04,0.0,0.0,0.050033491), :run => 16}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.04,0.04,0.0,0.0,0.077407734), :run => 16}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.12,0.049999999999999996,0.0,0.0,0.168728133), :run => 16}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.08,0.060000000000000005,0.0,0.0,0.133349474), :run => 16}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.02,0.04,0.0,0.0,0.053997862), :run => 17}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.02,0.03,0.0,0.0,0.053658925), :run => 17}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.03,0.05,0.0,0.0,0.079497632), :run => 17}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.07,0.03,0.0,0.0,0.103150871), :run => 17}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.05,0.08,0.0,0.0,0.12741451), :run => 17}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.01,0.009999999999999998,0.0,0.0,0.026427276), :run => 18}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.03,0.02,0.0,0.0,0.049729732), :run => 18}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.04,0.03,0.0,0.0,0.081266186), :run => 18}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.05,0.06,0.0,0.0,0.098927945), :run => 18}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.09,0.04,0.0,0.0,0.123772263), :run => 18}
{:ruby => "ruby 1.9.4dev patched", :size => 675, :bench => :require, :tms => Viiite::Tms(0.03,0.019999999999999997,0.0,0.0,0.049760074), :run => 19}
{:ruby => "ruby 1.9.4dev patched", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.01,0.04,0.0,0.0,0.052923046), :run => 19}
{:ruby => "ruby 1.9.4dev patched", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.04,0.04,0.0,0.0,0.076449627), :run => 19}
{:ruby => "ruby 1.9.4dev patched", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.06,0.04,0.0,0.0,0.101557392), :run => 19}
{:ruby => "ruby 1.9.4dev patched", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.08,0.04,0.0,0.0,0.126003357), :run => 19}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.08,0.03,0.0,0.0,0.106425714), :run => 0}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.11,0.03,0.0,0.0,0.13766555), :run => 0}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.23,0.03,0.0,0.0,0.262493943), :run => 0}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.34,0.07,0.0,0.0,0.404622244), :run => 0}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.4,0.08,0.0,0.0,0.477702928), :run => 0}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.04,0.03,0.0,0.0,0.066087553), :run => 1}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.12,0.02,0.0,0.0,0.141911248), :run => 1}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.19,0.04,0.0,0.0,0.234968578), :run => 1}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.29,0.06,0.0,0.0,0.345072326), :run => 1}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.4,0.07,0.0,0.0,0.475357094), :run => 1}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.060000000000000005,0.04,0.0,0.0,0.100198086), :run => 2}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.15,0.03,0.0,0.0,0.189206466), :run => 2}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.25,0.04,0.0,0.0,0.284410189), :run => 2}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.3,0.07,0.0,0.0,0.372347126), :run => 2}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.44,0.07,0.0,0.0,0.517308505), :run => 2}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.08,0.03,0.0,0.0,0.110216033), :run => 3}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.17,0.04,0.0,0.0,0.20620093), :run => 3}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.27,0.06,0.0,0.0,0.339734921), :run => 3}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.3,0.06,0.0,0.0,0.357001067), :run => 3}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.44,0.05,0.0,0.0,0.564311393), :run => 3}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.05,0.01,0.0,0.0,0.062840909), :run => 4}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.13,0.060000000000000005,0.0,0.0,0.185470813), :run => 4}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.27,0.08,0.0,0.0,0.343565045), :run => 4}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.36,0.07,0.0,0.0,0.424451681), :run => 4}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.47,0.06,0.0,0.0,0.527357368), :run => 4}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.04,0.03,0.0,0.0,0.073382702), :run => 5}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.1,0.04,0.0,0.0,0.147212248), :run => 5}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.18,0.06,0.0,0.0,0.242206978), :run => 5}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.29,0.07,0.0,0.0,0.361046623), :run => 5}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.39,0.09,0.0,0.0,0.485576466), :run => 5}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.05,0.02,0.0,0.0,0.064424875), :run => 6}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.16,0.060000000000000005,0.0,0.0,0.219490788), :run => 6}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.19,0.049999999999999996,0.0,0.0,0.239957909), :run => 6}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.3,0.05,0.0,0.0,0.362626084), :run => 6}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.42,0.06,0.0,0.0,0.485039672), :run => 6}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.05,0.01,0.0,0.0,0.072119075), :run => 7}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.12,0.03,0.0,0.0,0.148253988), :run => 7}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.2,0.04,0.0,0.0,0.241445787), :run => 7}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.26,0.09,0.0,0.0,0.357085235), :run => 7}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.41,0.09,0.0,0.0,0.495516984), :run => 7}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.06,0.019999999999999997,0.0,0.0,0.079270412), :run => 8}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.2,0.060000000000000005,0.0,0.0,0.262645554), :run => 8}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.22,0.049999999999999996,0.0,0.0,0.266084927), :run => 8}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.43,0.07,0.0,0.0,0.505548769), :run => 8}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.44,0.05,0.0,0.0,0.50875452), :run => 8}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.04,0.03,0.0,0.0,0.078001663), :run => 9}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.1,0.06,0.0,0.0,0.157824736), :run => 9}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.28,0.1,0.0,0.0,0.380234624), :run => 9}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.29,0.08,0.0,0.0,0.379296649), :run => 9}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.48,0.14,0.0,0.0,0.619103613), :run => 9}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.06,0.01,0.0,0.0,0.068383412), :run => 10}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.12,0.04,0.0,0.0,0.154398693), :run => 10}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.2,0.06,0.0,0.0,0.257092036), :run => 10}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.31,0.06,0.0,0.0,0.374274536), :run => 10}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.59,0.08,0.0,0.0,0.687259818), :run => 10}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.06,0.01,0.0,0.0,0.077039359), :run => 11}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.18,0.06,0.0,0.0,0.230433912), :run => 11}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.34,0.08,0.0,0.0,0.425458474), :run => 11}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.4,0.05,0.0,0.0,0.446377601), :run => 11}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.64,0.14,0.0,0.0,0.794722494), :run => 11}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.060000000000000005,0.02,0.0,0.0,0.074892732), :run => 12}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.13,0.04,0.0,0.0,0.168706823), :run => 12}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.24,0.04,0.0,0.0,0.283962925), :run => 12}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.3,0.09,0.0,0.0,0.390126106), :run => 12}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.56,0.19,0.0,0.0,0.753373284), :run => 12}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.07,0.05,0.0,0.0,0.12008506), :run => 13}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.14,0.06,0.0,0.0,0.198276342), :run => 13}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.22,0.04,0.0,0.0,0.263225785), :run => 13}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.33,0.06,0.0,0.0,0.392027778), :run => 13}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.46,0.07,0.0,0.0,0.543435577), :run => 13}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.06,0.01,0.0,0.0,0.073214707), :run => 14}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.13,0.03,0.0,0.0,0.155469519), :run => 14}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.21,0.05,0.0,0.0,0.261926831), :run => 14}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.31,0.07,0.0,0.0,0.3864906), :run => 14}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.55,0.11,0.0,0.0,0.665619062), :run => 14}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.04,0.03,0.0,0.0,0.078265869), :run => 15}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.13,0.06,0.0,0.0,0.182083704), :run => 15}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.21,0.049999999999999996,0.0,0.0,0.273254302), :run => 15}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.34,0.06,0.0,0.0,0.397724761), :run => 15}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.4,0.13,0.0,0.0,0.541044586), :run => 15}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.060000000000000005,0.02,0.0,0.0,0.074065756), :run => 16}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.17,0.04,0.0,0.0,0.214057825), :run => 16}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.25,0.05,0.0,0.0,0.301869013), :run => 16}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.42,0.09,0.0,0.0,0.515457108), :run => 16}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.63,0.13,0.0,0.0,0.762448221), :run => 16}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.08,0.02,0.0,0.0,0.097758721), :run => 17}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.15,0.02,0.0,0.0,0.165753029), :run => 17}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.24,0.04,0.0,0.0,0.291858081), :run => 17}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.41,0.08,0.0,0.0,0.487054463), :run => 17}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.45,0.08,0.0,0.0,0.537042021), :run => 17}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.06,0.04,0.0,0.0,0.102041219), :run => 18}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.14,0.02,0.0,0.0,0.162361295), :run => 18}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.36,0.12,0.0,0.0,0.479821357), :run => 18}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.37,0.06,0.0,0.0,0.431044726), :run => 18}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.45,0.1,0.0,0.0,0.550988632), :run => 18}
{:ruby => "ruby 1.9.4dev", :size => 675, :bench => :require, :tms => Viiite::Tms(0.06,0.019999999999999997,0.0,0.0,0.083784112), :run => 19}
{:ruby => "ruby 1.9.4dev", :size => 1175, :bench => :require, :tms => Viiite::Tms(0.12,0.05,0.0,0.0,0.172598331), :run => 19}
{:ruby => "ruby 1.9.4dev", :size => 1675, :bench => :require, :tms => Viiite::Tms(0.24,0.04,0.0,0.0,0.287833432), :run => 19}
{:ruby => "ruby 1.9.4dev", :size => 2175, :bench => :require, :tms => Viiite::Tms(0.33,0.07,0.0,0.0,0.408668532), :run => 19}
{:ruby => "ruby 1.9.4dev", :size => 2675, :bench => :require, :tms => Viiite::Tms(0.44,0.1,0.0,0.0,0.560012887), :run => 19}
# From https://gist.github.com/c8d0d422a9203e1fe492, modified
require 'tmpdir'
require 'fileutils'
Viiite.bench do |b|
b.variation_point :ruby, (ENV["RUBY"] || Viiite.which_ruby)
org_loaded_feature_size = $LOADED_FEATURES.size
Dir.mktmpdir do |dir|
2500.times do |i|
FileUtils.touch("#{dir}/bogus#{i}.rb")
end
$LOAD_PATH.unshift(dir)
(1..5).map { |n| n*500 }.each do |size|
b.variation_point :size, org_loaded_feature_size+size
fork do
x = 0
b.report(:require) do
size.times do
require "bogus#{x}"
x += 1
end
end
end
Process.wait
end
end
end
$ viiite report -h --regroup=ruby,size require.data.rash
+-----------------------+-------------------------------------------------------+
| :ruby | :measure |
+-----------------------+-------------------------------------------------------+
| ruby 1.9.4dev | +-------+----------+----------+----------+----------+ |
| | | :size | :user | :system | :total | :real | |
| | +-------+----------+----------+----------+----------+ |
| | | 675 | 0.058000 | 0.024000 | 0.082000 | 0.083125 | |
| | | 1175 | 0.138500 | 0.042500 | 0.181000 | 0.180001 | |
| | | 1675 | 0.239500 | 0.056000 | 0.295500 | 0.298070 | |
| | | 2175 | 0.334000 | 0.069000 | 0.403000 | 0.404917 | |
| | | 2675 | 0.473000 | 0.094500 | 0.567500 | 0.577599 | |
| | +-------+----------+----------+----------+----------+ |
| ruby 1.9.4dev patched | +-------+----------+----------+----------+----------+ |
| | | :size | :user | :system | :total | :real | |
| | +-------+----------+----------+----------+----------+ |
| | | 675 | 0.015000 | 0.021000 | 0.036000 | 0.035654 | |
| | | 1175 | 0.021000 | 0.032500 | 0.053500 | 0.052941 | |
| | | 1675 | 0.041500 | 0.038500 | 0.080000 | 0.080769 | |
| | | 2175 | 0.055500 | 0.055500 | 0.111000 | 0.110107 | |
| | | 2675 | 0.072500 | 0.066500 | 0.139000 | 0.141477 | |
| | +-------+----------+----------+----------+----------+ |
+-----------------------+-------------------------------------------------------+
@funny-falcon

This comment has been minimized.

Copy link

commented Oct 12, 2011

I tried to test "worst case" yesterday. It seems that 10000 requires of 'enc/encdb' (second required file) after 2000 other required files with patched version is worse by only ~0.05 seconds (0.56s on patched version instead of 0.52s on unpatched). But overall saved time is about 1.5s (patched version takes 1.137s, unpatched 2.694s) - requiring of 2000 files compensates any slowdown of requiring 'enc/encdb' :)

$LOAD_PATH.unshift(`pwd`.chomp)
2000.times{|i|
  require "tmp/#{i}"
  require "tmp/r#{i}"
}
require 'benchmark'
include Benchmark
bm do|b|
  b.report('require'){ 10000.times{ 
  require 'enc/encdb'
  } }
end

(tmp directory were filled with require "fileutils"; 2000.times{|i| FileUtils.touch("tmp/#{i}.rb"); FileUtils.touch("tmp/r#{i}.rb") }

@rdp

This comment has been minimized.

Copy link

commented Oct 13, 2011

I assume the axis is "time elapsed"?

@eregon

This comment has been minimized.

Copy link
Owner Author

commented Oct 13, 2011

@rdp yes, I should have added that. The x-axis is the the number of requires and the y-axis is the real time elapsed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.