-
-
Save headius/5167793 to your computer and use it in GitHub Desktop.
Benchmark and results of Time.new.to_i versus java.lang.System.nanoTime called from JRuby.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calculating ------------------------------------- | |
Time.new.to_i 106740 i/100ms | |
System.nanoTime 187876 i/100ms | |
------------------------------------------------- | |
Time.new.to_i 5457230.7 (±7.3%) i/s - 27111960 in 5.000000s | |
System.nanoTime 17952011.5 (±9.2%) i/s - 88301720 in 4.976000s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
java_import java.lang.System | |
Benchmark.ips do |bm| | |
bm.report('Time.new.to_i') do |n| | |
while n > 0 | |
Time.new.to_i | |
n-=1 | |
end | |
end | |
bm.report('System.nanoTime') do |n| | |
while n > 0 | |
System.nano_time | |
n-=1 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment