[PATCH v3 lkp-tests] /stats add proc-vmstat.rb

[Why] convert stats/proc-vmstat to proc_vmstat() of proc-vmstat.rb Signed-off-by: Lu Weitao <luweitaobe@163.com> --- stats/proc-vmstat.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 stats/proc-vmstat.rb diff --git a/stats/proc-vmstat.rb b/stats/proc-vmstat.rb new file mode 100644 index 000000000..279257cb6 --- /dev/null +++ b/stats/proc-vmstat.rb @@ -0,0 +1,24 @@ +# input: each line of test log with Array(String) structure which like: +# [ +# "time: 1600586885", +# "nr_free_pages 87512", +# ... +# "time: 1600586886", +# "nr_free_pages 87787", +# ... +# ] +# return eg: +# { +# "time"=>[1600586885, 1600586886], +# "nr_free_pages"=>[87512, 87787], +# ... +# } +def proc_vmstat(log_lines) + result = Hash.new { |hash, key| hash[key] = [] } + log_lines.each do |line| + key, value = line.split(/:?\s+/) + result[key] << value.to_i + end + + result +end -- 2.23.0
participants (1)
-
Lu Weitao