From 577e6379200f629c0bab3c954221dd22b9520f41 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 22 Mar 2018 13:43:41 +0100 Subject: reimplement percentile function --- .../profiling/latency_profile/profile_analyzer.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tools/profiling') diff --git a/tools/profiling/latency_profile/profile_analyzer.py b/tools/profiling/latency_profile/profile_analyzer.py index d4d14ef8c7..ad453a9eb0 100755 --- a/tools/profiling/latency_profile/profile_analyzer.py +++ b/tools/profiling/latency_profile/profile_analyzer.py @@ -184,24 +184,24 @@ for cs in call_stacks: def percentile(N, percent, key=lambda x: x): """ - Find the percentile of a list of values. + Find the percentile of an already sorted list of values. - @parameter N - is a list of values. Note N MUST BE already sorted. - @parameter percent - a float value from 0.0 to 1.0. + @parameter N - is a list of values. MUST be already sorted. + @parameter percent - a float value from [0.0,1.0]. @parameter key - optional key function to compute value from each element of N. @return - the percentile of the values """ if not N: return None - k = (len(N) - 1) * percent - f = math.floor(k) - c = math.ceil(k) - if f == c: - return key(N[int(k)]) - d0 = key(N[int(f)]) * (c - k) - d1 = key(N[int(c)]) * (k - f) - return d0 + d1 + idx = (len(N) - 1) * percent + idx_floor = math.floor(idx) + idx_ceil = math.ceil(idx) + if idx_floor != idx_ceil: + # interpolate the nearest element values + return (key(N[int(idx_floor)]) * (idx_ceil - idx) + + key(N[int(idx_ceil)]) * (idx - idx_floor)) + return key(N[int(idx)]) def tidy_tag(tag): -- cgit v1.2.3 From 9f40b5f29361d74c4891d8dfee112cff6a2d13c0 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 22 Mar 2018 16:51:24 +0100 Subject: further improve percentile() code --- tools/profiling/latency_profile/profile_analyzer.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'tools/profiling') diff --git a/tools/profiling/latency_profile/profile_analyzer.py b/tools/profiling/latency_profile/profile_analyzer.py index ad453a9eb0..cdc2f1cbab 100755 --- a/tools/profiling/latency_profile/profile_analyzer.py +++ b/tools/profiling/latency_profile/profile_analyzer.py @@ -194,14 +194,13 @@ def percentile(N, percent, key=lambda x: x): """ if not N: return None - idx = (len(N) - 1) * percent - idx_floor = math.floor(idx) - idx_ceil = math.ceil(idx) - if idx_floor != idx_ceil: - # interpolate the nearest element values - return (key(N[int(idx_floor)]) * (idx_ceil - idx) + - key(N[int(idx_ceil)]) * (idx - idx_floor)) - return key(N[int(idx)]) + float_idx = (len(N) - 1) * percent + idx = int(float_idx) + result = key(N[idx]) + if idx < len(N) - 1: + # interpolate with the next element's value + result += (float_idx - idx) * (key(N[idx + 1]) - key(N[idx])) + return result def tidy_tag(tag): -- cgit v1.2.3 From 746479ad804170970056f09ef4c6631d44d67b14 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 11 Apr 2018 21:58:55 +0200 Subject: fix performance profile jobs --- tools/profiling/microbenchmarks/bm2bq.py | 8 ++++---- tools/profiling/microbenchmarks/bm_json.py | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'tools/profiling') diff --git a/tools/profiling/microbenchmarks/bm2bq.py b/tools/profiling/microbenchmarks/bm2bq.py index e084e28dcf..c5307c52bd 100755 --- a/tools/profiling/microbenchmarks/bm2bq.py +++ b/tools/profiling/microbenchmarks/bm2bq.py @@ -1,9 +1,5 @@ #!/usr/bin/env python2.7 # -# Convert google-benchmark json output to something that can be uploaded to -# BigQuery -# -# # Copyright 2017 gRPC authors. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,6 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Convert google-benchmark json output to something that can be uploaded to +# BigQuery + import sys import json import csv @@ -54,6 +53,7 @@ if len(sys.argv) > 2: else: js2 = None +# TODO(jtattermusch): write directly to a file instead of stdout writer = csv.DictWriter(sys.stdout, [c for c, t in columns]) for row in bm_json.expand_json(js, js2): diff --git a/tools/profiling/microbenchmarks/bm_json.py b/tools/profiling/microbenchmarks/bm_json.py index 497d7ca813..2f5eb708de 100644 --- a/tools/profiling/microbenchmarks/bm_json.py +++ b/tools/profiling/microbenchmarks/bm_json.py @@ -12,8 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Utilities for manipulating JSON data that represents microbenchmark results. + import os +# template arguments and dynamic arguments of individual benchmark types +# Example benchmark name: "BM_UnaryPingPong/0/0" _BM_SPECS = { 'BM_UnaryPingPong': { 'tpl': ['fixture', 'client_mutator', 'server_mutator'], @@ -115,6 +119,7 @@ _BM_SPECS = { def numericalize(s): + """Convert abbreviations like '100M' or '10k' to a number.""" if not s: return '' if s[-1] == 'k': return float(s[:-1]) * 1024 @@ -159,9 +164,6 @@ def parse_name(name): rest = s[0] dyn_args = s[1:] name = rest - print(name) - print(dyn_args, _BM_SPECS[name]['dyn']) - print(tpl_args, _BM_SPECS[name]['tpl']) assert name in _BM_SPECS, '_BM_SPECS needs to be expanded for %s' % name assert len(dyn_args) == len(_BM_SPECS[name]['dyn']) assert len(tpl_args) == len(_BM_SPECS[name]['tpl']) -- cgit v1.2.3 From 99e910f58fa54e9bce2518c6f9752ba1e8dbd6af Mon Sep 17 00:00:00 2001 From: ncteisen Date: Fri, 27 Apr 2018 11:34:50 -0700 Subject: Stop tracking call size in bm diff --- tools/profiling/microbenchmarks/bm_diff/bm_constants.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'tools/profiling') diff --git a/tools/profiling/microbenchmarks/bm_diff/bm_constants.py b/tools/profiling/microbenchmarks/bm_diff/bm_constants.py index 5719e42620..c8b6c1ebd0 100644 --- a/tools/profiling/microbenchmarks/bm_diff/bm_constants.py +++ b/tools/profiling/microbenchmarks/bm_diff/bm_constants.py @@ -22,11 +22,10 @@ _AVAILABLE_BENCHMARK_TESTS = [ 'bm_metadata', 'bm_fullstack_trickle' ] -_INTERESTING = ('cpu_time', 'real_time', 'call_initial_size-median', - 'locks_per_iteration', 'allocs_per_iteration', - 'writes_per_iteration', 'atm_cas_per_iteration', - 'atm_add_per_iteration', 'nows_per_iteration', - 'cli_transport_stalls_per_iteration', +_INTERESTING = ('cpu_time', 'real_time', 'locks_per_iteration', + 'allocs_per_iteration', 'writes_per_iteration', + 'atm_cas_per_iteration', 'atm_add_per_iteration', + 'nows_per_iteration', 'cli_transport_stalls_per_iteration', 'cli_stream_stalls_per_iteration', 'svr_transport_stalls_per_iteration', 'svr_stream_stalls_per_iteration', -- cgit v1.2.3