Skip to content

Instantly share code, notes, and snippets.

@anicholson
Created March 15, 2017 02:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
user system total real
Run 0 14.010000 0.470000 14.480000 ( 2.773481)
Run 1 2.700000 0.210000 2.910000 ( 0.635449)
Run 2 1.170000 0.010000 1.180000 ( 0.300033)
Run 3 1.930000 0.080000 2.010000 ( 0.372750)
Run 4 1.430000 0.020000 1.450000 ( 0.325396)
Run 5 1.460000 0.020000 1.480000 ( 0.346627)
Run 6 1.350000 0.060000 1.410000 ( 0.366876)
Run 7 1.230000 0.020000 1.250000 ( 0.356951)
Run 8 1.020000 0.010000 1.030000 ( 0.452953)
Run 9 0.940000 0.010000 0.950000 ( 0.320790)
Run 10 0.890000 0.000000 0.890000 ( 0.317094)
Run 11 0.790000 0.010000 0.800000 ( 0.322072)
Run 12 0.750000 0.010000 0.760000 ( 0.304630)
Run 13 0.670000 0.010000 0.680000 ( 0.287382)
Run 14 0.640000 0.010000 0.650000 ( 0.284209)
Run 15 0.560000 0.000000 0.560000 ( 0.278113)
Run 16 0.340000 0.010000 0.350000 ( 0.319395)
Run 17 0.700000 0.010000 0.710000 ( 0.284337)
Run 18 1.240000 0.020000 1.260000 ( 0.365978)
Run 19 1.090000 0.010000 1.100000 ( 0.353917)
14.010000 0.470000 14.480000 ( 2.773481)
2.700000 0.210000 2.910000 ( 0.635449)
1.170000 0.010000 1.180000 ( 0.300033)
1.930000 0.080000 2.010000 ( 0.372750)
1.430000 0.020000 1.450000 ( 0.325396)
1.460000 0.020000 1.480000 ( 0.346627)
1.350000 0.060000 1.410000 ( 0.366876)
1.230000 0.020000 1.250000 ( 0.356951)
1.020000 0.010000 1.030000 ( 0.452953)
0.940000 0.010000 0.950000 ( 0.320790)
0.890000 0.000000 0.890000 ( 0.317094)
0.790000 0.010000 0.800000 ( 0.322072)
0.750000 0.010000 0.760000 ( 0.304630)
0.670000 0.010000 0.680000 ( 0.287382)
0.640000 0.010000 0.650000 ( 0.284209)
0.560000 0.000000 0.560000 ( 0.278113)
0.340000 0.010000 0.350000 ( 0.319395)
0.700000 0.010000 0.710000 ( 0.284337)
1.240000 0.020000 1.260000 ( 0.365978)
1.090000 0.010000 1.100000 ( 0.353917)
user system total real
Run 0 22.680000 0.920000 23.600000 ( 5.462016)
Run 1 13.720000 0.320000 14.040000 ( 3.922979)
Run 2 13.180000 0.250000 13.430000 ( 3.879744)
Run 3 12.910000 0.210000 13.120000 ( 3.722721)
Run 4 12.910000 0.220000 13.130000 ( 3.810211)
Run 5 13.190000 0.200000 13.390000 ( 3.679315)
Run 6 13.290000 0.230000 13.520000 ( 3.827539)
Run 7 13.570000 0.280000 13.850000 ( 3.879293)
Run 8 13.360000 0.220000 13.580000 ( 3.812677)
Run 9 13.320000 0.230000 13.550000 ( 3.707130)
Run 10 13.220000 0.220000 13.440000 ( 3.724456)
Run 11 13.020000 0.230000 13.250000 ( 3.763944)
Run 12 12.790000 0.210000 13.000000 ( 3.778035)
Run 13 13.300000 0.220000 13.520000 ( 3.759488)
Run 14 13.240000 0.190000 13.430000 ( 3.730533)
Run 15 12.830000 0.260000 13.090000 ( 4.331377)
Run 16 13.370000 0.240000 13.610000 ( 3.918521)
Run 17 13.210000 0.210000 13.420000 ( 3.769924)
Run 18 13.300000 0.240000 13.540000 ( 3.832422)
Run 19 13.520000 0.210000 13.730000 ( 3.779636)
22.680000 0.920000 23.600000 ( 5.462016)
13.720000 0.320000 14.040000 ( 3.922979)
13.180000 0.250000 13.430000 ( 3.879744)
12.910000 0.210000 13.120000 ( 3.722721)
12.910000 0.220000 13.130000 ( 3.810211)
13.190000 0.200000 13.390000 ( 3.679315)
13.290000 0.230000 13.520000 ( 3.827539)
13.570000 0.280000 13.850000 ( 3.879293)
13.360000 0.220000 13.580000 ( 3.812677)
13.320000 0.230000 13.550000 ( 3.707130)
13.220000 0.220000 13.440000 ( 3.724456)
13.020000 0.230000 13.250000 ( 3.763944)
12.790000 0.210000 13.000000 ( 3.778035)
13.300000 0.220000 13.520000 ( 3.759488)
13.240000 0.190000 13.430000 ( 3.730533)
12.830000 0.260000 13.090000 ( 4.331377)
13.370000 0.240000 13.610000 ( 3.918521)
13.210000 0.210000 13.420000 ( 3.769924)
13.300000 0.240000 13.540000 ( 3.832422)
13.520000 0.210000 13.730000 ( 3.779636)
user system total real
Run 0 25.120000 1.050000 26.170000 ( 5.727648)
Run 1 10.780000 0.410000 11.190000 ( 3.603226)
Run 2 11.180000 0.230000 11.410000 ( 4.488935)
Run 3 11.690000 0.290000 11.980000 ( 4.385633)
Run 4 11.230000 0.180000 11.410000 ( 4.087830)
Run 5 5.460000 0.060000 5.520000 ( 1.963376)
Run 6 11.490000 0.360000 11.850000 ( 4.443970)
Run 7 5.280000 0.050000 5.330000 ( 2.019938)
Run 8 11.130000 0.200000 11.330000 ( 4.470521)
Run 9 5.440000 0.070000 5.510000 ( 2.151182)
Run 10 11.140000 0.150000 11.290000 ( 4.361468)
Run 11 5.260000 0.040000 5.300000 ( 1.911055)
Run 12 10.850000 0.250000 11.100000 ( 4.080048)
Run 13 5.440000 0.050000 5.490000 ( 1.983724)
Run 14 10.790000 0.120000 10.910000 ( 3.997888)
Run 15 5.500000 0.050000 5.550000 ( 2.042450)
Run 16 10.830000 0.150000 10.980000 ( 4.198473)
Run 17 5.380000 0.050000 5.430000 ( 2.072873)
Run 18 11.110000 0.140000 11.250000 ( 4.056517)
Run 19 5.460000 0.060000 5.520000 ( 2.069925)
25.120000 1.050000 26.170000 ( 5.727648)
10.780000 0.410000 11.190000 ( 3.603226)
11.180000 0.230000 11.410000 ( 4.488935)
11.690000 0.290000 11.980000 ( 4.385633)
11.230000 0.180000 11.410000 ( 4.087830)
5.460000 0.060000 5.520000 ( 1.963376)
11.490000 0.360000 11.850000 ( 4.443970)
5.280000 0.050000 5.330000 ( 2.019938)
11.130000 0.200000 11.330000 ( 4.470521)
5.440000 0.070000 5.510000 ( 2.151182)
11.140000 0.150000 11.290000 ( 4.361468)
5.260000 0.040000 5.300000 ( 1.911055)
10.850000 0.250000 11.100000 ( 4.080048)
5.440000 0.050000 5.490000 ( 1.983724)
10.790000 0.120000 10.910000 ( 3.997888)
5.500000 0.050000 5.550000 ( 2.042450)
10.830000 0.150000 10.980000 ( 4.198473)
5.380000 0.050000 5.430000 ( 2.072873)
11.110000 0.140000 11.250000 ( 4.056517)
5.460000 0.060000 5.520000 ( 2.069925)
user system total real
Run 0 1.630000 0.060000 1.690000 ( 1.699709)
Run 1 1.650000 0.080000 1.730000 ( 1.725957)
Run 2 1.700000 0.070000 1.770000 ( 1.776696)
Run 3 1.770000 0.100000 1.870000 ( 1.871721)
Run 4 1.730000 0.050000 1.780000 ( 1.792233)
Run 5 1.750000 0.090000 1.840000 ( 1.849431)
Run 6 1.790000 0.060000 1.850000 ( 1.843765)
Run 7 1.610000 0.080000 1.690000 ( 1.688677)
Run 8 1.700000 0.050000 1.750000 ( 1.759494)
Run 9 1.760000 0.080000 1.840000 ( 1.845578)
Run 10 1.780000 0.090000 1.870000 ( 1.875588)
Run 11 1.640000 0.080000 1.720000 ( 1.711264)
Run 12 1.690000 0.100000 1.790000 ( 1.803149)
Run 13 1.800000 0.070000 1.870000 ( 1.862207)
Run 14 1.720000 0.080000 1.800000 ( 1.801800)
Run 15 1.730000 0.100000 1.830000 ( 1.843260)
Run 16 1.640000 0.070000 1.710000 ( 1.700402)
Run 17 1.580000 0.080000 1.660000 ( 1.667592)
Run 18 1.730000 0.110000 1.840000 ( 1.837664)
Run 19 1.750000 0.080000 1.830000 ( 1.841172)
1.630000 0.060000 1.690000 ( 1.699709)
1.650000 0.080000 1.730000 ( 1.725957)
1.700000 0.070000 1.770000 ( 1.776696)
1.770000 0.100000 1.870000 ( 1.871721)
1.730000 0.050000 1.780000 ( 1.792233)
1.750000 0.090000 1.840000 ( 1.849431)
1.790000 0.060000 1.850000 ( 1.843765)
1.610000 0.080000 1.690000 ( 1.688677)
1.700000 0.050000 1.750000 ( 1.759494)
1.760000 0.080000 1.840000 ( 1.845578)
1.780000 0.090000 1.870000 ( 1.875588)
1.640000 0.080000 1.720000 ( 1.711264)
1.690000 0.100000 1.790000 ( 1.803149)
1.800000 0.070000 1.870000 ( 1.862207)
1.720000 0.080000 1.800000 ( 1.801800)
1.730000 0.100000 1.830000 ( 1.843260)
1.640000 0.070000 1.710000 ( 1.700402)
1.580000 0.080000 1.660000 ( 1.667592)
1.730000 0.110000 1.840000 ( 1.837664)
1.750000 0.080000 1.830000 ( 1.841172)
user system total real
Run 0 1.640000 0.080000 1.720000 ( 1.718627)
Run 1 1.700000 0.100000 1.800000 ( 1.808482)
Run 2 1.880000 0.090000 1.970000 ( 2.022068)
Run 3 1.740000 0.110000 1.850000 ( 1.853544)
Run 4 1.660000 0.080000 1.740000 ( 1.753238)
Run 5 1.710000 0.100000 1.810000 ( 1.821392)
Run 6 1.650000 0.080000 1.730000 ( 1.738556)
Run 7 1.770000 0.100000 1.870000 ( 1.892510)
Run 8 1.660000 0.080000 1.740000 ( 1.746067)
Run 9 1.700000 0.100000 1.800000 ( 1.799191)
Run 10 1.650000 0.090000 1.740000 ( 1.739059)
Run 11 1.790000 0.110000 1.900000 ( 1.903821)
Run 12 1.670000 0.060000 1.730000 ( 1.732364)
Run 13 1.770000 0.090000 1.860000 ( 1.864105)
Run 14 1.810000 0.090000 1.900000 ( 1.909463)
Run 15 1.640000 0.080000 1.720000 ( 1.718989)
Run 16 1.720000 0.090000 1.810000 ( 1.821302)
Run 17 1.600000 0.080000 1.680000 ( 1.678015)
Run 18 1.630000 0.080000 1.710000 ( 1.714420)
Run 19 1.670000 0.080000 1.750000 ( 1.758951)
1.640000 0.080000 1.720000 ( 1.718627)
1.700000 0.100000 1.800000 ( 1.808482)
1.880000 0.090000 1.970000 ( 2.022068)
1.740000 0.110000 1.850000 ( 1.853544)
1.660000 0.080000 1.740000 ( 1.753238)
1.710000 0.100000 1.810000 ( 1.821392)
1.650000 0.080000 1.730000 ( 1.738556)
1.770000 0.100000 1.870000 ( 1.892510)
1.660000 0.080000 1.740000 ( 1.746067)
1.700000 0.100000 1.800000 ( 1.799191)
1.650000 0.090000 1.740000 ( 1.739059)
1.790000 0.110000 1.900000 ( 1.903821)
1.670000 0.060000 1.730000 ( 1.732364)
1.770000 0.090000 1.860000 ( 1.864105)
1.810000 0.090000 1.900000 ( 1.909463)
1.640000 0.080000 1.720000 ( 1.718989)
1.720000 0.090000 1.810000 ( 1.821302)
1.600000 0.080000 1.680000 ( 1.678015)
1.630000 0.080000 1.710000 ( 1.714420)
1.670000 0.080000 1.750000 ( 1.758951)
def sieve_upto(top)
sieve = [nil, nil] + (2..top).to_a
for i in 2 .. Math.sqrt(top)
next unless sieve[i]
(i*i).step(top, i) do |j|
sieve[j] = nil
end
end
sieve.compact
end
require 'benchmark'
timings = Benchmark.bm(7) do |x|
20.times do |i|
x.report("Run #{i}".to_sym) { sieve_upto 9_000_000 }
end
end
puts timings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment