Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
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():
verbose
=
0
quiet
=
0
dostats
=
1
print_histogram
=
0
interval
=
900
# Every 15 minutes
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"i:qvS"
)
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"i:qvS
h
"
)
except
getopt
.
error
,
msg
:
usage
(
msg
)
return
2
...
...
@@ -82,7 +83,10 @@ def main():
verbose
=
1
if
o
==
"-S"
:
dostats
=
0
verbose
=
1
quiet
=
0
if
o
==
'-h'
:
print_histogram
=
1
if
len
(
args
)
!=
1
:
usage
(
"exactly one file argument required"
)
return
2
...
...
@@ -104,6 +108,8 @@ def main():
datarecords
=
0
datasize
=
0L
file0
=
file1
=
0
oids
=
{}
total_loads
=
0
byinterval
=
{}
thisinterval
=
None
h0
=
he
=
None
...
...
@@ -150,6 +156,9 @@ def main():
U64
(
serial
),
version
,
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
not
quiet
:
dumpbyinterval
(
byinterval
,
h0
,
he
)
...
...
@@ -162,6 +171,7 @@ def main():
print
'='
*
20
,
"Restart"
,
'='
*
20
else
:
print
'-'
*
20
,
"Flip->%d"
%
current
,
'-'
*
20
bytes
=
f
.
tell
()
f
.
close
()
rte
=
time
.
time
()
...
...
@@ -198,6 +208,25 @@ def main():
addcommas
(
bycode
.
get
(
code
,
0
)),
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
):
loads
=
0
...
...
@@ -232,6 +261,14 @@ def hitrate(bycode):
else
:
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
):
h
,
v
=
struct
.
unpack
(
">II"
,
s
)
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