Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZEO
Commits
f6c5cc13
Commit
f6c5cc13
authored
Sep 06, 2002
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add -h option to produce histogram
parent
e49ce291
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
1 deletion
+38
-1
src/ZEO/stats.py
src/ZEO/stats.py
+38
-1
No files found.
src/ZEO/stats.py
View file @
f6c5cc13
...
@@ -62,9 +62,10 @@ def main():
...
@@ -62,9 +62,10 @@ def main():
verbose
=
0
verbose
=
0
quiet
=
0
quiet
=
0
dostats
=
1
dostats
=
1
print_histogram
=
0
interval
=
900
# Every 15 minutes
interval
=
900
# Every 15 minutes
try
:
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"i:qvS"
)
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"i:qvS
h
"
)
except
getopt
.
error
,
msg
:
except
getopt
.
error
,
msg
:
usage
(
msg
)
usage
(
msg
)
return
2
return
2
...
@@ -82,7 +83,10 @@ def main():
...
@@ -82,7 +83,10 @@ def main():
verbose
=
1
verbose
=
1
if
o
==
"-S"
:
if
o
==
"-S"
:
dostats
=
0
dostats
=
0
verbose
=
1
quiet
=
0
quiet
=
0
if
o
==
'-h'
:
print_histogram
=
1
if
len
(
args
)
!=
1
:
if
len
(
args
)
!=
1
:
usage
(
"exactly one file argument required"
)
usage
(
"exactly one file argument required"
)
return
2
return
2
...
@@ -104,6 +108,8 @@ def main():
...
@@ -104,6 +108,8 @@ def main():
datarecords
=
0
datarecords
=
0
datasize
=
0L
datasize
=
0L
file0
=
file1
=
0
file0
=
file1
=
0
oids
=
{}
total_loads
=
0
byinterval
=
{}
byinterval
=
{}
thisinterval
=
None
thisinterval
=
None
h0
=
he
=
None
h0
=
he
=
None
...
@@ -150,6 +156,9 @@ def main():
...
@@ -150,6 +156,9 @@ def main():
U64
(
serial
),
U64
(
serial
),
version
,
version
,
dlen
and
str
(
dlen
)
or
""
)
dlen
and
str
(
dlen
)
or
""
)
if
code
&
0x70
==
0x20
:
oids
[
oid
]
=
oids
.
get
(
oid
,
0
)
+
1
total_loads
+=
1
if
code
in
(
0x00
,
0x70
):
if
code
in
(
0x00
,
0x70
):
if
not
quiet
:
if
not
quiet
:
dumpbyinterval
(
byinterval
,
h0
,
he
)
dumpbyinterval
(
byinterval
,
h0
,
he
)
...
@@ -162,6 +171,7 @@ def main():
...
@@ -162,6 +171,7 @@ def main():
print
'='
*
20
,
"Restart"
,
'='
*
20
print
'='
*
20
,
"Restart"
,
'='
*
20
else
:
else
:
print
'-'
*
20
,
"Flip->%d"
%
current
,
'-'
*
20
print
'-'
*
20
,
"Flip->%d"
%
current
,
'-'
*
20
bytes
=
f
.
tell
()
bytes
=
f
.
tell
()
f
.
close
()
f
.
close
()
rte
=
time
.
time
()
rte
=
time
.
time
()
...
@@ -198,6 +208,25 @@ def main():
...
@@ -198,6 +208,25 @@ def main():
addcommas
(
bycode
.
get
(
code
,
0
)),
addcommas
(
bycode
.
get
(
code
,
0
)),
code
,
code
,
explain
.
get
(
code
)
or
"*** unknown code ***"
)
explain
.
get
(
code
)
or
"*** unknown code ***"
)
if
print_histogram
:
print
print
"Histogram of object load frequency"
total
=
len
(
oids
)
s
=
addcommas
(
total
)
print
"Unique oids: %s"
%
addcommas
(
total
)
print
"Total loads: %s"
%
addcommas
(
total_loads
)
width
=
max
(
len
(
s
),
len
(
"objects"
))
fmt
=
"%5d %"
+
str
(
width
)
+
"s %3d%% %5.1f%% %4d%%"
hdr
=
"%5s %"
+
str
(
width
)
+
"s %4s %6s %5s"
print
hdr
%
(
"loads"
,
"objects"
,
"%obj"
,
"%load"
,
"%cum"
)
cum
=
0.0
for
binsize
,
count
in
histogram
(
oids
):
obj_percent
=
100
*
count
/
total
load_percent
=
1000
*
count
*
binsize
/
total_loads
load_percent
/=
10.
cum
+=
load_percent
print
fmt
%
(
binsize
,
addcommas
(
count
),
obj_percent
,
load_percent
,
cum
)
def
dumpbyinterval
(
byinterval
,
h0
,
he
):
def
dumpbyinterval
(
byinterval
,
h0
,
he
):
loads
=
0
loads
=
0
...
@@ -232,6 +261,14 @@ def hitrate(bycode):
...
@@ -232,6 +261,14 @@ def hitrate(bycode):
else
:
else
:
return
0.0
return
0.0
def
histogram
(
d
):
bins
=
{}
for
v
in
d
.
itervalues
():
bins
[
v
]
=
bins
.
get
(
v
,
0
)
+
1
L
=
bins
.
items
()
L
.
sort
()
return
L
def
U64
(
s
):
def
U64
(
s
):
h
,
v
=
struct
.
unpack
(
">II"
,
s
)
h
,
v
=
struct
.
unpack
(
">II"
,
s
)
return
(
long
(
h
)
<<
32
)
+
v
return
(
long
(
h
)
<<
32
)
+
v
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment