FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
google-cloud-cpp/plot2.py at data · dopiera/google-cloud-cpp · GitHub
dopiera
/
google-cloud-cpp
Public
forked from
googleapis/google-cloud-cpp
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
google-cloud-cpp
/
plot2.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
125 lines (106 loc) · 3.73 KB
Breadcrumbs
google-cloud-cpp
/
plot2.py
Copy path
File metadata and controls
125 lines (106 loc) · 3.73 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import
math
import
os
import
os
.
path
import
re
import
subprocess
import
sys
import
tempfile
def
usage
(
msg
=
None
):
if
msg
is
not
None
:
print
msg
print
"%s: directory filter_expr dimensions_to_plot"
%
sys
.
argv
[
0
]
print
"Fields available for filtering and plotting are: "
print
(
"op, file_sz, chunk_sz, buffer_sz, wall_time, cpu_use, bw, "
"cpu_per_byte, crc, md5, weight, progress"
)
sys
.
exit
(
1
)
def
read_file
(
f
):
res
=
[]
for
line
in
open
(
f
).
readlines
():
if
not
line
.
lstrip
():
continue
if
line
.
lstrip
().
startswith
(
'#'
):
continue
(
op
,
file_size
,
chunk_size
,
buffer_size
,
crc
,
md5
,
wall_time
,
cpu_time
,
prob
,
status
,
prog
,
version
)
=
line
.
rstrip
(
'
\n
'
).
split
(
','
)
if
status
<>
'OK'
:
print
"Warning: not OK status"
file_size
=
int
(
file_size
)
chunk_size
=
int
(
chunk_size
)
buffer_size
=
int
(
buffer_size
)
wall_time
=
int
(
wall_time
)
cpu_time
=
int
(
cpu_time
)
crc
=
crc
==
'true'
md5
=
md5
==
'true'
weight
=
1
/
float
(
prob
)
prog
=
[[
int
(
i
)
for
i
in
time_point
.
split
(
'|'
)]
for
time_point
in
prog
.
split
(
';'
)]
sample
=
{}
sample
[
"op"
]
=
op
sample
[
"file_sz"
]
=
file_size
/
1048576.
sample
[
"chunk_sz"
]
=
chunk_size
/
1048576.
sample
[
"buffer_sz"
]
=
buffer_size
/
1048576.
sample
[
"wall_time"
]
=
wall_time
sample
[
"cpu_use"
]
=
float
(
cpu_time
)
/
wall_time
sample
[
"bw"
]
=
float
(
file_size
)
/
int
(
wall_time
)
sample
[
"cpu_per_byte"
]
=
float
(
cpu_time
)
/
file_size
sample
[
"crc"
]
=
crc
sample
[
"md5"
]
=
md5
sample
[
"weight"
]
=
weight
sample
[
"progress"
]
=
prog
res
.
append
(
sample
)
return
res
def
escape
(
s
):
return
s
.
replace
(
'
\\
'
,
'
\\
\\
'
).
replace
(
'"'
,
'
\\
"'
).
replace
(
'_'
,
'
\\
_'
)
class
Stats
:
def
__init__
(
self
):
self
.
sum
=
0.
self
.
num
=
0
self
.
sum_square
=
0.
self
.
weight_sum
=
0
def
add
(
self
,
x
,
weight
):
self
.
weight_sum
=
self
.
weight_sum
+
weight
self
.
num
=
self
.
num
+
1
self
.
sum
=
self
.
sum
+
x
*
weight
self
.
sum_square
=
self
.
sum_square
+
x
*
x
*
weight
def
show
(
self
):
ex
=
self
.
sum
/
self
.
weight_sum
print
"Samples=%s EX=%.02f, SD=%.02f"
%
(
self
.
num
,
ex
,
math
.
sqrt
(
self
.
sum_square
/
self
.
weight_sum
-
ex
*
ex
))
def
run_gnuplot
(
res
,
fields
,
filt
):
f
=
tempfile
.
NamedTemporaryFile
()
print
>>
f
,
"$map1 << EOD"
stats
=
Stats
()
for
sample
in
res
:
weight
=
sample
[
-
1
]
data
=
sample
[:
-
1
]
stats
.
add
(
data
[
-
1
],
weight
)
print
>>
f
,
' '
.
join
([
str
(
s
)
for
s
in
data
])
print
>>
f
,
"EOD"
if
len
(
fields
)
==
3
:
print
>>
f
,
"set title
\"
(%s, %s) -> %s for %s
\"
"
%
(
fields
[
0
],
fields
[
1
],
fields
[
2
],
escape
(
filt
))
print
>>
f
,
"splot $map1 with points pt 7 palette"
else
:
print
>>
f
,
"set title
\"
%s -> %s for %s
\"
"
%
(
fields
[
0
],
fields
[
1
],
escape
(
filt
))
print
>>
f
,
"set yrange[0:%s]"
%
(
max
([
sample
[
1
]
for
sample
in
res
])
*
1.1
)
print
>>
f
,
"plot $map1 with points pt 7 "
f
.
flush
()
stats
.
show
()
subprocess
.
Popen
([
'/usr/bin/gnuplot'
,
f
.
name
,
'-'
]).
wait
()
def
main
():
if
len
(
sys
.
argv
)
<>
4
:
usage
()
file
=
sys
.
argv
[
1
]
filt
=
sys
.
argv
[
2
]
fields
=
sys
.
argv
[
3
].
split
(
','
)
if
len
(
fields
)
<>
2
and
len
(
fields
)
<>
3
:
usage
(
"expected 2 or 3 comma-separated fields, got %s"
,
len
(
fields
))
res
=
[[
row
[
field
]
for
field
in
fields
]
+
[
row
[
"weight"
]]
for
row
in
read_file
(
file
)
if
eval
(
filt
,
None
,
row
)]
res
.
sort
()
run_gnuplot
(
res
,
fields
,
filt
)
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL