create memory--stat.cr as same content with memory--stat
Signed-off-by: Lu Kaiyi 2392863668@qq.com --- stats/crystal/memory--stat.cr | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 stats/crystal/memory--stat.cr
diff --git a/stats/crystal/memory--stat.cr b/stats/crystal/memory--stat.cr new file mode 100644 index 000000000..1a39e4075 --- /dev/null +++ b/stats/crystal/memory--stat.cr @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby + +# time: 123456 +# cgroup: pmbench.1 +# cache 0 + +def parse + cg = 'nocg' + $stdin.each_line do |line| + case line + when /^time:/ + puts line + when /^cgroup: (\S+)/ + cg = $1 + when /(\S+)\s*(\S+)/ + k, v, = line.split + puts "#{cg}.#{k}: #{v}" + end + end +end + +parse
On Wed, Jan 13, 2021 at 10:22:57AM +0800, Lu Kaiyi wrote:
create memory--stat.cr as same content with memory--stat
Signed-off-by: Lu Kaiyi 2392863668@qq.com
stats/crystal/memory--stat.cr | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 stats/crystal/memory--stat.cr
diff --git a/stats/crystal/memory--stat.cr b/stats/crystal/memory--stat.cr new file mode 100644 index 000000000..1a39e4075 --- /dev/null +++ b/stats/crystal/memory--stat.cr @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby
shebang is wrong, please fix crystal.
+# time: 123456 +# cgroup: pmbench.1 +# cache 0
it's best to give some inputs and outputs.
+def parse
- cg = 'nocg'
- $stdin.each_line do |line|
- case line
- when /^time:/
puts line
- when /^cgroup: (\S+)/
cg = $1
- when /(\S+)\s*(\S+)/
k, v, = line.split
^----- why to need ',' ?
Thanks, Liushaofei
puts "#{cg}.#{k}: #{v}"
- end
- end
+end
+parse
2.23.0