Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zodbtools
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
zodbtools
Commits
7d24147b
Commit
7d24147b
authored
Jan 08, 2019
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
analyze: use print function for python3 compatibility
parent
b4824ad5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
36 deletions
+38
-36
zodbtools/zodbanalyze.py
zodbtools/zodbanalyze.py
+38
-36
No files found.
zodbtools/zodbanalyze.py
View file @
7d24147b
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
# Based on a transaction analyzer by Matt Kromer.
# Based on a transaction analyzer by Matt Kromer.
from
__future__
import
print_function
import
sys
import
sys
import
os
import
os
import
getopt
import
getopt
...
@@ -95,16 +97,16 @@ def report(rep, csv=False):
...
@@ -95,16 +97,16 @@ def report(rep, csv=False):
delta_fs
=
rep
.
delta_fs
delta_fs
=
rep
.
delta_fs
if
not
csv
:
if
not
csv
:
if
rep
.
TIDS
==
0
:
if
rep
.
TIDS
==
0
:
print
"No transactions processed"
print
(
"No transactions processed"
)
return
return
print
"# %s..%s"
%
(
ashex
(
rep
.
tidmin
),
ashex
(
rep
.
tidmax
))
print
(
"# %s..%s"
%
(
ashex
(
rep
.
tidmin
),
ashex
(
rep
.
tidmax
)
))
print
"Processed %d records in %d transactions"
%
(
rep
.
OIDS
,
rep
.
TIDS
)
print
(
"Processed %d records in %d transactions"
%
(
rep
.
OIDS
,
rep
.
TIDS
)
)
print
"Average record size is %7.2f bytes"
%
(
rep
.
DBYTES
*
1.0
/
rep
.
OIDS
)
print
(
"Average record size is %7.2f bytes"
%
(
rep
.
DBYTES
*
1.0
/
rep
.
OIDS
)
)
print
(
"Average transaction size is %7.2f bytes"
%
print
(
"Average transaction size is %7.2f bytes"
%
(
rep
.
DBYTES
*
1.0
/
rep
.
TIDS
))
(
rep
.
DBYTES
*
1.0
/
rep
.
TIDS
))
print
"Types used:"
print
(
"Types used:"
)
if
delta_fs
:
if
delta_fs
:
if
csv
:
if
csv
:
fmt
=
"%s,%s,%s,%s,%s"
fmt
=
"%s,%s,%s,%s,%s"
...
@@ -112,9 +114,9 @@ def report(rep, csv=False):
...
@@ -112,9 +114,9 @@ def report(rep, csv=False):
else
:
else
:
fmt
=
"%-46s %7s %9s %6s %7s"
fmt
=
"%-46s %7s %9s %6s %7s"
fmtp
=
"%-46s %7d %9d %5.1f%% %7.2f"
# per-class format
fmtp
=
"%-46s %7d %9d %5.1f%% %7.2f"
# per-class format
print
fmt
%
(
"Class Name"
,
"T.Count"
,
"T.Bytes"
,
"Pct"
,
"AvgSize"
)
print
(
fmt
%
(
"Class Name"
,
"T.Count"
,
"T.Bytes"
,
"Pct"
,
"AvgSize"
)
)
if
not
csv
:
if
not
csv
:
print
fmt
%
(
'-'
*
46
,
'-'
*
7
,
'-'
*
9
,
'-'
*
5
,
'-'
*
7
)
print
(
fmt
%
(
'-'
*
46
,
'-'
*
7
,
'-'
*
9
,
'-'
*
5
,
'-'
*
7
)
)
else
:
else
:
if
csv
:
if
csv
:
fmt
=
"%s,%s,%s,%s,%s,%s,%s,%s,%s"
fmt
=
"%s,%s,%s,%s,%s,%s,%s,%s,%s"
...
@@ -122,10 +124,10 @@ def report(rep, csv=False):
...
@@ -122,10 +124,10 @@ def report(rep, csv=False):
else
:
else
:
fmt
=
"%-46s %7s %9s %6s %7s %7s %9s %7s %9s"
fmt
=
"%-46s %7s %9s %6s %7s %7s %9s %7s %9s"
fmtp
=
"%-46s %7d %9d %5.1f%% %7.2f %7d %9d %7d %9d"
# per-class format
fmtp
=
"%-46s %7d %9d %5.1f%% %7.2f %7d %9d %7d %9d"
# per-class format
print
fmt
%
(
"Class Name"
,
"T.Count"
,
"T.Bytes"
,
"Pct"
,
"AvgSize"
,
print
(
fmt
%
(
"Class Name"
,
"T.Count"
,
"T.Bytes"
,
"Pct"
,
"AvgSize"
,
"C.Count"
,
"C.Bytes"
,
"O.Count"
,
"O.Bytes"
)
"C.Count"
,
"C.Bytes"
,
"O.Count"
,
"O.Bytes"
)
)
if
not
csv
:
if
not
csv
:
print
fmt
%
(
'-'
*
46
,
'-'
*
7
,
'-'
*
9
,
'-'
*
5
,
'-'
*
7
,
'-'
*
7
,
'-'
*
9
,
'-'
*
7
,
'-'
*
9
)
print
(
fmt
%
(
'-'
*
46
,
'-'
*
7
,
'-'
*
9
,
'-'
*
5
,
'-'
*
7
,
'-'
*
7
,
'-'
*
9
,
'-'
*
7
,
'-'
*
9
)
)
fmts
=
"%46s %7d %8dk %5.1f%% %7.2f"
# summary format
fmts
=
"%46s %7d %8dk %5.1f%% %7.2f"
# summary format
typemap
=
rep
.
TYPEMAP
.
keys
()
typemap
=
rep
.
TYPEMAP
.
keys
()
typemap
.
sort
(
key
=
lambda
a
:
rep
.
TYPESIZE
[
a
])
typemap
.
sort
(
key
=
lambda
a
:
rep
.
TYPESIZE
[
a
])
...
@@ -138,37 +140,37 @@ def report(rep, csv=False):
...
@@ -138,37 +140,37 @@ def report(rep, csv=False):
else
:
else
:
t_display
=
shorten
(
t
,
46
)
t_display
=
shorten
(
t
,
46
)
if
delta_fs
:
if
delta_fs
:
print
fmtp
%
(
t_display
,
rep
.
TYPEMAP
[
t
],
rep
.
TYPESIZE
[
t
],
print
(
fmtp
%
(
t_display
,
rep
.
TYPEMAP
[
t
],
rep
.
TYPESIZE
[
t
],
pct
,
rep
.
TYPESIZE
[
t
]
*
1.0
/
rep
.
TYPEMAP
[
t
]
)
pct
,
rep
.
TYPESIZE
[
t
]
*
1.0
/
rep
.
TYPEMAP
[
t
])
)
else
:
else
:
print
fmtp
%
(
t_display
,
rep
.
TYPEMAP
[
t
],
rep
.
TYPESIZE
[
t
],
print
(
fmtp
%
(
t_display
,
rep
.
TYPEMAP
[
t
],
rep
.
TYPESIZE
[
t
],
pct
,
rep
.
TYPESIZE
[
t
]
*
1.0
/
rep
.
TYPEMAP
[
t
],
pct
,
rep
.
TYPESIZE
[
t
]
*
1.0
/
rep
.
TYPEMAP
[
t
],
rep
.
COIDSMAP
[
t
],
rep
.
CBYTESMAP
[
t
],
rep
.
COIDSMAP
[
t
],
rep
.
CBYTESMAP
[
t
],
rep
.
FOIDSMAP
.
get
(
t
,
0
),
rep
.
FBYTESMAP
.
get
(
t
,
0
))
rep
.
FOIDSMAP
.
get
(
t
,
0
),
rep
.
FBYTESMAP
.
get
(
t
,
0
)
))
if
csv
:
if
csv
:
return
return
if
delta_fs
:
if
delta_fs
:
print
fmt
%
(
'='
*
46
,
'='
*
7
,
'='
*
9
,
'='
*
5
,
'='
*
7
)
print
(
fmt
%
(
'='
*
46
,
'='
*
7
,
'='
*
9
,
'='
*
5
,
'='
*
7
)
)
print
"%46s %7d %9s %6s %6.2f"
%
(
'Total Transactions'
,
rep
.
TIDS
,
' '
,
print
(
"%46s %7d %9s %6s %6.2f"
%
(
'Total Transactions'
,
rep
.
TIDS
,
' '
,
' '
,
rep
.
DBYTES
*
1.0
/
rep
.
TIDS
)
' '
,
rep
.
DBYTES
*
1.0
/
rep
.
TIDS
)
)
print
fmts
%
(
'Total Records'
,
rep
.
OIDS
,
rep
.
DBYTES
,
cumpct
,
print
(
fmts
%
(
'Total Records'
,
rep
.
OIDS
,
rep
.
DBYTES
,
cumpct
,
rep
.
DBYTES
*
1.0
/
rep
.
OIDS
)
rep
.
DBYTES
*
1.0
/
rep
.
OIDS
)
)
else
:
else
:
print
fmt
%
(
'='
*
46
,
'='
*
7
,
'='
*
9
,
'='
*
5
,
'='
*
7
,
'='
*
7
,
'='
*
9
,
'='
*
7
,
'='
*
9
)
print
(
fmt
%
(
'='
*
46
,
'='
*
7
,
'='
*
9
,
'='
*
5
,
'='
*
7
,
'='
*
7
,
'='
*
9
,
'='
*
7
,
'='
*
9
)
)
print
"%46s %7d %9s %6s %6.2fk"
%
(
'Total Transactions'
,
rep
.
TIDS
,
' '
,
print
(
"%46s %7d %9s %6s %6.2fk"
%
(
'Total Transactions'
,
rep
.
TIDS
,
' '
,
' '
,
rep
.
DBYTES
*
1.0
/
rep
.
TIDS
/
1024.0
)
' '
,
rep
.
DBYTES
*
1.0
/
rep
.
TIDS
/
1024.0
)
)
print
fmts
%
(
'Total Records'
,
rep
.
OIDS
,
rep
.
DBYTES
/
1024.0
,
cumpct
,
print
(
fmts
%
(
'Total Records'
,
rep
.
OIDS
,
rep
.
DBYTES
/
1024.0
,
cumpct
,
rep
.
DBYTES
*
1.0
/
rep
.
OIDS
)
rep
.
DBYTES
*
1.0
/
rep
.
OIDS
)
)
print
fmts
%
(
'Current Objects'
,
rep
.
COIDS
,
rep
.
CBYTES
/
1024.0
,
print
(
fmts
%
(
'Current Objects'
,
rep
.
COIDS
,
rep
.
CBYTES
/
1024.0
,
rep
.
CBYTES
*
100.0
/
rep
.
DBYTES
,
rep
.
CBYTES
*
100.0
/
rep
.
DBYTES
,
rep
.
CBYTES
*
1.0
/
rep
.
COIDS
)
rep
.
CBYTES
*
1.0
/
rep
.
COIDS
)
)
if
rep
.
FOIDS
:
if
rep
.
FOIDS
:
print
fmts
%
(
'Old Objects'
,
rep
.
FOIDS
,
rep
.
FBYTES
/
1024.0
,
print
(
fmts
%
(
'Old Objects'
,
rep
.
FOIDS
,
rep
.
FBYTES
/
1024.0
,
rep
.
FBYTES
*
100.0
/
rep
.
DBYTES
,
rep
.
FBYTES
*
100.0
/
rep
.
DBYTES
,
rep
.
FBYTES
*
1.0
/
rep
.
FOIDS
)
rep
.
FBYTES
*
1.0
/
rep
.
FOIDS
)
)
@
func
@
func
def
analyze
(
path
,
use_dbm
,
delta_fs
,
tidmin
,
tidmax
):
def
analyze
(
path
,
use_dbm
,
delta_fs
,
tidmin
,
tidmax
):
...
@@ -240,7 +242,7 @@ def analyze_rec(report, record):
...
@@ -240,7 +242,7 @@ def analyze_rec(report, record):
report
.
TYPEMAP
[
type
]
=
report
.
TYPEMAP
.
get
(
type
,
0
)
+
1
report
.
TYPEMAP
[
type
]
=
report
.
TYPEMAP
.
get
(
type
,
0
)
+
1
report
.
TYPESIZE
[
type
]
=
report
.
TYPESIZE
.
get
(
type
,
0
)
+
size
report
.
TYPESIZE
[
type
]
=
report
.
TYPESIZE
.
get
(
type
,
0
)
+
size
except
Exception
,
err
:
except
Exception
,
err
:
print
err
print
(
err
,
file
=
sys
.
stderr
)
__doc__
=
"""%(program)s: Analyzer for ZODB data or repozo deltafs
__doc__
=
"""%(program)s: Analyzer for ZODB data or repozo deltafs
...
@@ -262,9 +264,9 @@ summary = "analyze ZODB database or repozo deltafs usage"
...
@@ -262,9 +264,9 @@ summary = "analyze ZODB database or repozo deltafs usage"
def
usage
(
stream
,
msg
=
None
):
def
usage
(
stream
,
msg
=
None
):
if
msg
:
if
msg
:
print
>>
stream
,
msg
print
(
msg
,
file
=
stream
)
print
>>
stream
print
(
file
=
stream
)
print
>>
stream
,
__doc__
%
{
"program"
:
"zodb analyze"
}
print
(
__doc__
%
{
"program"
:
"zodb analyze"
},
file
=
stream
)
def
main
(
argv
):
def
main
(
argv
):
...
...
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