1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
diff --unified --recursive --text cloudflare-blog.orig/2017-06-29-ssdp/mmhistogram cloudflare-blog.new/2017-06-29-ssdp/mmhistogram
--- cloudflare-blog.orig/2017-06-29-ssdp/mmhistogram 2023-09-06 00:55:02.952366159 +0200
+++ cloudflare-blog.new/2017-06-29-ssdp/mmhistogram 2023-09-06 00:50:10.223048641 +0200
@@ -1,8 +1,9 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python
+
import argparse
import itertools
-import math
import sys
+import statistics
parser = argparse.ArgumentParser(description='Print log-2 histogram, like systemtap')
parser.add_argument('-t', '--title', default="Values",
@@ -31,10 +32,10 @@
totalcount = len(M)
minval = M[-1]
maxval = M[0]
-avgval = sum(M) / float(len(M))
-devval = math.sqrt(sum([(m - avgval)**2 for m in M]) / float(len(M)))
+avgval = statistics.mean(M)
+devval = statistics.stdev(M)
+medval = statistics.median(M)
-medval = M[len(M)/2]
KV = []
@@ -65,35 +66,41 @@
maxbound = KV[-1][0]
boundl = max(len(str(maxbound)), len('value'))
-print "%s min:%.2f avg:%.2f med=%.2f max:%.2f dev:%.2f count:%d" % (
+print_values = "%s min:%.2f avg:%.2f med=%.2f max:%.2f dev:%.2f count:%d" % (
args.title,
minval,
avgval,
medval,
maxval,
devval,
- totalcount,
+ totalcount
)
-print "%s:" % (
+print(print_values)
+
+print_title = "%s:" % (
args.title,
)
-print "%*s |%*s %s" % (
+print(print_title)
+
+print_column = "%*s |%*s %s" % (
boundl+1,
"value",
args.columns,
"-" * args.columns,
"count"
)
+print(print_column)
for boundb, bound, c in KV:
if args.percentage:
cp = "%5.2f%%" % ((c / float(totalcount))*100.0,)
else:
cp = "%d" % (c,)
- print "%*d |%*s %s" % (
+ print_bound = "%*d |%*s %s" % (
boundl + 1,
boundb,
args.columns,
"*" * int(args.columns * (c/maxcount)),
cp
)
+ print(print_bound)
diff --unified --recursive --text cloudflare-blog.orig/2017-06-29-ssdp/mmsum cloudflare-blog.new/2017-06-29-ssdp/mmsum
--- cloudflare-blog.orig/2017-06-29-ssdp/mmsum 2023-09-06 00:55:02.952366159 +0200
+++ cloudflare-blog.new/2017-06-29-ssdp/mmsum 2023-09-05 22:01:48.306100235 +0200
@@ -6,4 +6,4 @@
for line in sys.stdin:
s += float(line)
-print s
+print(s)
Only in cloudflare-blog.orig/2017-06-29-ssdp: mmwatch
|