diff --git a/src/html_files/analytics.ts b/src/html_files/analytics.ts new file mode 100644 index 00000000..380d9afb --- /dev/null +++ b/src/html_files/analytics.ts @@ -0,0 +1,68 @@ +class Rule { + name: string; + single_run_rule?: RuleCall; + all_run_rule?: RuleCall; + per_run_rule?: RuleCall; +} + +interface RuleCall { + (opts: RuleOpts): Generator; +} + +class Rules { + data_type: string; + pretty_name: string; + rules: Array; +} + +class RuleOpts { + data_type: string; + runs: Array; + key: string; + all_data: any; + base_run: string; + base_run_data: any; + this_run: any; + this_run_data: any; + other_run_data: Map; + per_run_data: Array; +} + +enum Status { + Good = '✅', + NotGood = '❌', +} + +class Analytics { + name: string; + analysis: Array; +} + +class Finding { + text: string; + status: Status; + recommendation: string; + + constructor(text: string = '', status: Status = Status.NotGood, recommendation: string = '') { + this.text = text; + this.status = status; + this.recommendation = recommendation; + } + + is_good() { + this.status = Status.Good; + } + + is_not_good() { + this.status = Status.NotGood; + } +} + +function is_unique(values_array) { + return new Set(values_array).size == 1; +} + +let all_rules: Rules[] = [ + system_info_rules, + cpu_utilization_rules, +]; \ No newline at end of file diff --git a/src/html_files/cpu_utilization.ts b/src/html_files/cpu_utilization.ts index 4e7f1c11..927ff374 100644 --- a/src/html_files/cpu_utilization.ts +++ b/src/html_files/cpu_utilization.ts @@ -1,6 +1,50 @@ let got_cpu_util_data = false; let util_cpu_list: Map = new Map(); +let cpu_utilization_rules = { + data_type: "cpu_utilization", + pretty_name: "CPU Utilization", + rules: [ + { + name: "User", + single_run_rule: function* (opts): Generator { + let system_util = get_data_key(opts.data_type, "System"); + let total_util: number = opts.base_run_data + system_util.get(opts.base_run); + if (total_util < 50) { + yield new Finding( + `Average CPU Utilization for '${opts.base_run}' is less than 50%.`, + Status.NotGood, + ); + } + }, + per_run_rule: function* (opts): Generator { + let system_util = get_data_key(opts.data_type, "System"); + let init_total_util: number = opts.base_run_data + system_util.get(opts.base_run); + let run_total_util: number = opts.this_run_data + system_util.get(opts.this_run); + let cpu_diff = Math.ceil(Math.abs(run_total_util - init_total_util)); + yield new Finding( + `Average CPU Utilization difference between '${opts.base_run}' and '${opts.this_run}' is ${cpu_diff}%.`, + cpu_diff > 10 ? Status.NotGood : Status.Good, + ); + }, + }, + { + name: "Idle", + single_run_rule: function* (opts): Generator { + if (opts.base_run_data > 50) { + yield new Finding(`Average Idle time for '${opts.base_run}' is greater than 50%.`, Status.NotGood); + } + }, + per_run_rule: function* (opts): Generator { + let idle_diff = Math.ceil(Math.abs(opts.this_run_data - opts.base_run_data)); + yield new Finding( + `Average Idle time difference between '${opts.base_run}' and '${opts.this_run}' is ${idle_diff}%.`, + idle_diff > 10 ? Status.NotGood : Status.Good, + ) + }, + } + ] +} function getUtilizationType(run, elem, type, run_data) { var cpu_type_datas = []; var type_data; diff --git a/src/html_files/flamegraphs.ts b/src/html_files/flamegraphs.ts index f2e69585..38ff5252 100644 --- a/src/html_files/flamegraphs.ts +++ b/src/html_files/flamegraphs.ts @@ -34,11 +34,9 @@ function getFlamegraphInfo(run, container_id) { addElemToNode(container_id, div); } -function flamegraphs(set: boolean|string) { +function flamegraphs(set) { if (set == got_flamegraphs_data) { return; - } else if (typeof(set) == "boolean") { - set = "flamegraphs"; } got_flamegraphs_data = set; clear_and_create('flamegraphs'); diff --git a/src/html_files/index.html b/src/html_files/index.html index 90b464a4..3ee83d66 100644 --- a/src/html_files/index.html +++ b/src/html_files/index.html @@ -11,7 +11,7 @@ APerf Configure - SUT Config + Report CPU Utilization Flamegraphs Top Functions @@ -30,6 +30,12 @@ + + Findings + System Info + + + @@ -131,6 +137,7 @@ Hide N/A and all-zero graphs: + @@ -149,6 +156,7 @@ Hide N/A and all-zero graphs: +