changeset 12:8abcef12fad7

Add benchmark.rb
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Tue, 06 Feb 2018 03:10:20 +0900
parents 7e3bd1c57033
children 922d6f6d0b67
files benchmark.rb
diffstat 1 files changed, 30 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/benchmark.rb	Tue Feb 06 03:10:20 2018 +0900
@@ -0,0 +1,30 @@
+require 'optparse'
+require 'pry'
+params = ARGV.getopts('', 'path:', 'length:1024', 'split:8', 'gpu', 'logDirPath:.')
+
+cpus = (0..4).map {|i| 2**i }
+Dir.chdir(params['logDirPath'])
+
+unless params['path']
+  puts 'Usage: ruby benchmark.rb --path gears_example_binary_path [options]'
+  puts '  --length length      array length [default: 1024]'
+  puts '  --split split        array split num [default: 8]'
+  puts '  --logDirPath logdir  log directory [default: current directory]'
+  puts '  --gpu                run gpu'
+  puts '  -h                   show help'
+  exit(1)
+end
+
+file = File.new("cpu_result", 'w')
+cpus.each do |i|
+  result = `#{params['path']} -cpu #{i} -l #{params['length']} -s #{params['split']}`
+  file.write(result)
+end
+file.close
+
+exit(0) unless params['gpu']
+
+file = File.new("gpu_result", 'w')
+result = `#{params['path']} -cpu #{i} -l #{params['length']} -s #{params['split']}`
+file.write(result)
+file.close