Created
February 18, 2018 06:51
-
-
Save sho-h/5b5d0ffec652cd184115d810ae097563 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 "tempfile" | |
data = "test" | |
[:flush, :fsync, :fdatasync].each do |method| | |
puts "---- #{method} ----" | |
res = [] | |
10.times do | |
Tempfile.open("testtmpfile") do |f| | |
before = Time.now | |
10000.times do |i| | |
f.print(data) | |
f.send(method) | |
end | |
res << (Time.now - before) | |
end | |
end | |
puts "#{method}: #{res.inject(0) {|res, t| res + t } / res.length} sec" | |
end | |
# ---- flush ---- | |
# flush: 0.06868516690000001 sec | |
# ---- fsync ---- | |
# fsync: 3.1406286125999996 sec | |
# ---- fdatasync ---- | |
# fdatasync: 3.1831921884 sec |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment