sample: sbin/compare "id=15104" "id=15409" --color
0 1 metric -------------------- ------------------------------ ------------------------------ %stddev change %stddev \ | \ 35110937.00 +2.0% 35854560.00 atomic.score 1.00 [93m+200.0% [0m 3.00 atomic.threads 11.14 +3.3% 11.51 atomic.time.elapsed_time 11.14 +3.3% 11.51 atomic.time.elapsed_time.max 22.00 [93m+27.0% [0m 28.00 atomic.time.involuntary_context_switches 4288.00 +1.0% 4352.00 atomic.time.maximum_resident_set_size 668.00 +0.0% 672.00 atomic.time.minor_page_faults 0.00 0 0.03 atomic.time.system_time 94.00 +10.0% 104.00 atomic.time.voluntary_context_switches 11.35 [93m+19.1% [0m 13.52 boot-time.boot 14.90 +14.8% 17.10 boot-time.idle 6990.00 [93m+56.0% [0m 10971.00 interrupts.2:GICv3.27.Level.arch_timer 463.00 [93m+313.0% [0m 1913.00 interrupts.38:GICv3.36.Level.virtio0 138.00 -3.0% 135.00 interrupts.45:ITS-MSI.32769.Edge.virtio1-control 3613.00 [93m+51.0% [0m 5473.00 interrupts.CPU0.2:GICv3.27.Level.arch_timer 138.00 -3.0% 135.00 interrupts.CPU0.45:ITS-MSI.32769.Edge.virtio1-control 1834.00 [93m+61.0% [0m 2968.00 interrupts.CPU0.IPI0:Rescheduling_interrupts 24.00 [91m-34.0% [0m 16.00 interrupts.CPU0.IPI1:Function_call_interrupts 3377.00 [93m+62.0% [0m 5498.00 interrupts.CPU1.2:GICv3.27.Level.arch_timer 463.00 [93m+313.0% [0m 1913.00 interrupts.CPU1.38:GICv3.36.Level.virtio0 1858.00 -8.0% 1723.00 interrupts.CPU1.IPI0:Rescheduling_interrupts 28.00 +7.0% 30.00 interrupts.CPU1.IPI1:Function_call_interrupts 3692.00 [93m+27.0% [0m 4691.00 interrupts.IPI0:Rescheduling_interrupts 52.00 -12.0% 46.00 interrupts.IPI1:Function_call_interrupts 375264.00 +8.0% 408058.00 meminfo.Active ...
Signed-off-by: Lu Weitao luweitao2@huawei.com --- lib/compare.rb | 8 ++++---- lib/compare_matrixes.rb | 7 +++---- sbin/compare | 18 ++++++++++++++++-- 3 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/lib/compare.rb b/lib/compare.rb index 4ef21b8..48367d9 100644 --- a/lib/compare.rb +++ b/lib/compare.rb @@ -16,10 +16,10 @@ require_relative './constants.rb' # - multiple conditions: "os=centos,debian suite=iperf,atomic" #
-def compare_matrices_list(argv, common_conditions) +def compare_matrices_list(argv, common_conditions, options) condition_list = parse_argv(argv, common_conditions) matrices_list = create_matrices_list(condition_list) - compare_matrixes(matrices_list) + compare_matrixes(matrices_list, options: options) end
def parse_argv(argv, common_conditions) @@ -53,11 +53,11 @@ end # - multiple dimensions: "os os_version ..." #
-def compare_group(argv, dimensions) +def compare_group(argv, dimensions, options) conditions = parse_conditions(argv) dims = dimensions.split(' ') groups_matrices = create_groups_matrices_list(conditions, dims) - compare_group_matrices(groups_matrices) + compare_group_matrices(groups_matrices, options) end
def create_groups_matrices_list(conditions, dims) diff --git a/lib/compare_matrixes.rb b/lib/compare_matrixes.rb index 9068073..b892826 100644 --- a/lib/compare_matrixes.rb +++ b/lib/compare_matrixes.rb @@ -187,7 +187,7 @@ def matrixes_empty?(matrixes_list) return matrixes_list.any?(&:empty?) end
-def compare_matrixes(matrixes_list, matrixes_titles = matrixes_list.size, group_key = nil, options = {}) +def compare_matrixes(matrixes_list, matrixes_titles = matrixes_list.size, group_key = nil, options: {}) # compare matrix in matrixes_list and print info # # @matrixes_list: list consisting of matrix @@ -199,7 +199,6 @@ def compare_matrixes(matrixes_list, matrixes_titles = matrixes_list.size, group_ warn 'Matrix cannot be empty!' return end - options = { 'perf-profile': 5, theme: :none }.merge(options) matrixes_values = get_matrixes_values(matrixes_list, options) remove_unchanged_field(matrixes_values) @@ -375,7 +374,7 @@ end # compare each matrices_list within pre dimension of group matrices # input: group matrices # output: pre compare result of each group -def compare_group_matrices(group_matrices) +def compare_group_matrices(group_matrices, options) group_matrices.each do |k, v| matrices_list = [] matrices_titles = [] @@ -384,7 +383,7 @@ def compare_group_matrices(group_matrices) matrices_list << matrix end
- compare_matrixes(matrices_list, matrices_titles, k) + compare_matrixes(matrices_list, matrices_titles, k, options: options) end end
diff --git a/sbin/compare b/sbin/compare index bc63ace..c171894 100755 --- a/sbin/compare +++ b/sbin/compare @@ -10,6 +10,7 @@ # compare "commit=a12d232e" "commit=b3bacc31" # compare "os=debian" "os=centos" -c "suite=iperf" # compare "os=centos" -d "os_version os_arch" +# compare "os=centos" -d "os_version os_arch" --color -t light
require 'optparse' require_relative '../lib/compare.rb' @@ -17,6 +18,9 @@ require_relative '../lib/compare.rb' common_conditions = '' is_group = false dimensions = nil +theme = :classic +color = false +options = {}
opt_parser = OptionParser.new do |opts| opts.banner = 'Usage: compare "conditions" ... [option]' @@ -36,6 +40,14 @@ opt_parser = OptionParser.new do |opts| is_group = true end
+ opts.on('-t', '--theme theme', 'theme to compare: classic/focus_good/focus_bad/striking/light') do |t| + theme = t + end + + opts.on('--color', 'turn on colorful display with current theme') do + color = true + end + opts.on_tail('-h', '--help', 'show this message') do puts opts exit @@ -49,8 +61,10 @@ argv = if ARGV == [] end opt_parser.parse!(argv)
+options = { theme: theme } if color + if is_group - compare_group(argv, dimensions) + compare_group(argv, dimensions, options) else - compare_matrices_list(argv, common_conditions) + compare_matrices_list(argv, common_conditions, options) end
@@ -199,7 +199,6 @@ def compare_matrixes(matrixes_list, matrixes_titles = matrixes_list.size, group_ warn 'Matrix cannot be empty!' return end
don't remove that line.
options = { 'perf-profile': 5, theme: :none }.merge(options) matrixes_values = get_matrixes_values(matrixes_list, options) remove_unchanged_field(matrixes_values)
@@ -375,7 +374,7 @@ end # compare each matrices_list within pre dimension of group matrices # input: group matrices # output: pre compare result of each group -def compare_group_matrices(group_matrices) +def compare_group_matrices(group_matrices, options) group_matrices.each do |k, v| matrices_list = [] matrices_titles = [] @@ -384,7 +383,7 @@ def compare_group_matrices(group_matrices) matrices_list << matrix end
- compare_matrixes(matrices_list, matrices_titles, k)
- compare_matrixes(matrices_list, matrices_titles, k, options: options) end
end
diff --git a/sbin/compare b/sbin/compare index bc63ace..c171894 100755 --- a/sbin/compare +++ b/sbin/compare @@ -10,6 +10,7 @@ # compare "commit=a12d232e" "commit=b3bacc31" # compare "os=debian" "os=centos" -c "suite=iperf" # compare "os=centos" -d "os_version os_arch" +# compare "os=centos" -d "os_version os_arch" --color -t light
require 'optparse' require_relative '../lib/compare.rb' @@ -17,6 +18,9 @@ require_relative '../lib/compare.rb' common_conditions = '' is_group = false dimensions = nil +theme = :classic +color = false +options = {}
opt_parser = OptionParser.new do |opts| opts.banner = 'Usage: compare "conditions" ... [option]' @@ -36,6 +40,14 @@ opt_parser = OptionParser.new do |opts| is_group = true end
- opts.on('-t', '--theme theme', 'theme to compare: classic/focus_good/focus_bad/striking/light') do |t|
- theme = t
- end
- opts.on('--color', 'turn on colorful display with current theme') do
- color = true
- end
这两个参数可以合并为一个吗?
--color none|classic|...
Thanks, Fengguang
On Fri, Aug 21, 2020 at 02:44:54PM +0800, Wu Fengguang wrote:
@@ -199,7 +199,6 @@ def compare_matrixes(matrixes_list, matrixes_titles = matrixes_list.size, group_ warn 'Matrix cannot be empty!' return end
don't remove that line.
got it.
options = { 'perf-profile': 5, theme: :none }.merge(options) matrixes_values = get_matrixes_values(matrixes_list, options) remove_unchanged_field(matrixes_values)
@@ -17,6 +18,9 @@ require_relative '../lib/compare.rb' common_conditions = '' is_group = false dimensions = nil +theme = :classic +color = false +options = {}
opt_parser = OptionParser.new do |opts| opts.banner = 'Usage: compare "conditions" ... [option]' @@ -36,6 +40,14 @@ opt_parser = OptionParser.new do |opts| is_group = true end
- opts.on('-t', '--theme theme', 'theme to compare: classic/focus_good/focus_bad/striking/light') do |t|
- theme = t
- end
- opts.on('--color', 'turn on colorful display with current theme') do
- color = true
- end
这两个参数可以合并为一个吗?
--color none|classic|...
yes, user give a theme: none|classic|focus_good|... with --color and "none" is default theme, the effect is same with without --color
Thanks, Weitao
Thanks, Fengguang