From 1060b32455320d33b0decf761d9139cd700b2c66 Mon Sep 17 00:00:00 2001 From: SpringMT Date: Thu, 11 Apr 2024 22:20:08 +0900 Subject: [PATCH] fix: benchmark format --- benchmarks/zstd_compress_memory.rb | 4 ++-- benchmarks/zstd_decompress_memory.rb | 2 +- benchmarks/zstd_streaming_compress_memory.rb | 3 ++- benchmarks/zstd_streaming_decompress_memory.rb | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/benchmarks/zstd_compress_memory.rb b/benchmarks/zstd_compress_memory.rb index c3beb31..d18e6e9 100644 --- a/benchmarks/zstd_compress_memory.rb +++ b/benchmarks/zstd_compress_memory.rb @@ -14,11 +14,11 @@ json_string = json_data.to_json i = 0 - +start_time = Time.now while true do Zstd.compress(json_string) if ((i % 1000) == 0 ) - puts "count:#{i}\truby_memory:#{ObjectSpace.memsize_of_all/1000}\tobject_count:#{ObjectSpace.count_objects}\trss:#{`ps -o rss= -p #{Process.pid}`.to_i}" + puts "sec:#{Time.now - start_time}\tcount:#{i}\truby_memory:#{ObjectSpace.memsize_of_all/1000}\tobject_count:#{ObjectSpace.count_objects}\trss:#{`ps -o rss= -p #{Process.pid}`.to_i}" end i += 1 end diff --git a/benchmarks/zstd_decompress_memory.rb b/benchmarks/zstd_decompress_memory.rb index 8f9d67b..e305355 100644 --- a/benchmarks/zstd_decompress_memory.rb +++ b/benchmarks/zstd_decompress_memory.rb @@ -16,7 +16,7 @@ while true do Zstd.decompress IO.read("./results/#{sample_file_name}.zstd") if ((i % 1000) == 0 ) - puts "count:#{i}\truby_memory:#{ObjectSpace.memsize_of_all/1000}\tobject_count:#{ObjectSpace.count_objects}\trss:#{`ps -o rss= -p #{Process.pid}`.to_i}" + puts "sec:#{Time.now - start_time}\tcount:#{i}\truby_memory:#{ObjectSpace.memsize_of_all/1000}\tobject_count:#{ObjectSpace.count_objects}\trss:#{`ps -o rss= -p #{Process.pid}`.to_i}" end i += 1 end diff --git a/benchmarks/zstd_streaming_compress_memory.rb b/benchmarks/zstd_streaming_compress_memory.rb index ce8d334..3ae99cf 100644 --- a/benchmarks/zstd_streaming_compress_memory.rb +++ b/benchmarks/zstd_streaming_compress_memory.rb @@ -13,6 +13,7 @@ json_string = IO.read("./samples/#{sample_file_name}") i = 0 +start_time = Time.now while true do stream = Zstd::StreamingCompress.new stream << json_string[0, 5] @@ -21,7 +22,7 @@ res << stream.finish if ((i % 1000) == 0 ) GC.start - puts "count:#{i}\truby_memory:#{ObjectSpace.memsize_of_all/1000}\tobject_count:#{ObjectSpace.count_objects}\trss:#{`ps -o rss= -p #{Process.pid}`.to_i}" + puts "sec:#{Time.now - start_time}\tcount:#{i}\truby_memory:#{ObjectSpace.memsize_of_all/1000}\tobject_count:#{ObjectSpace.count_objects}\trss:#{`ps -o rss= -p #{Process.pid}`.to_i}" end i += 1 end diff --git a/benchmarks/zstd_streaming_decompress_memory.rb b/benchmarks/zstd_streaming_decompress_memory.rb index 0f62a7a..166bd98 100644 --- a/benchmarks/zstd_streaming_decompress_memory.rb +++ b/benchmarks/zstd_streaming_decompress_memory.rb @@ -12,6 +12,7 @@ cstr = IO.read("./results/#{sample_file_name}.zstd") i = 0 +start_time = Time.now while true do stream = Zstd::StreamingDecompress.new result = '' @@ -20,7 +21,7 @@ if ((i % 1000) == 0 ) GC.start - puts "count:#{i}\truby_memory:#{ObjectSpace.memsize_of_all/1000}\tobject_count:#{ObjectSpace.count_objects}\trss:#{`ps -o rss= -p #{Process.pid}`.to_i}" + puts "sec:#{Time.now - start_time}\tcount:#{i}\truby_memory:#{ObjectSpace.memsize_of_all/1000}\tobject_count:#{ObjectSpace.count_objects}\trss:#{`ps -o rss= -p #{Process.pid}`.to_i}" end i += 1 end