Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Laurent S
erp5
Commits
08569a57
Commit
08569a57
authored
Nov 21, 2012
by
Tatuya Kamada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test: Add a test to check HBTreeFolder2 GET performace.
parent
e89d10aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
2 deletions
+82
-2
product/HBTreeFolder2/tests/testHBTreeFolder2.py
product/HBTreeFolder2/tests/testHBTreeFolder2.py
+82
-2
No files found.
product/HBTreeFolder2/tests/testHBTreeFolder2.py
View file @
08569a57
...
...
@@ -15,16 +15,20 @@
import
random
import
unittest
import
ZODB
import
Testing
from
Testing
import
ZopeTestCase
import
Zope2
from
Products.HBTreeFolder2.HBTreeFolder2
\
import
HBTreeFolder2
,
ExhaustedUniqueIdsError
from
OFS.ObjectManager
import
BadRequestException
from
OFS.Folder
import
Folder
from
Acquisition
import
aq_base
import
timeit
from
textwrap
import
dedent
from
Products.ERP5Type.tests.backportUnittest
import
expectedFailure
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
class
HBTreeFolder2Tests
(
unittest
.
TestCase
):
class
HBTreeFolder2Tests
(
ERP5Type
TestCase
):
def
getBase
(
self
,
ob
):
# This is overridden in subclasses.
...
...
@@ -226,6 +230,82 @@ class HBTreeFolder2Tests(unittest.TestCase):
id_list
.
remove
(
i
)
h
.
_delOb
(
i
)
@
expectedFailure
def
testPerformanceInDepth
(
self
):
"""
Check HBTreeFolder2 GET performance with the depth and the number of
documents.
"""
init_1
=
dedent
(
"""
from Products.HBTreeFolder2.HBTreeFolder2 import HBTreeFolder2
from Products.CMFDefault.File import File
h_depth_1 = HBTreeFolder2()
#from BTrees.OOBTree import OOBTree
#h_depth_1 = OOBTree()
for i in xrange(%d):
id = str(i)
h_depth_1[id] = File(id)
"""
)
init_2
=
dedent
(
"""
from Products.HBTreeFolder2.HBTreeFolder2 import HBTreeFolder2
from Products.CMFDefault.File import File
h_depth_2 = HBTreeFolder2()
#from BTrees.OOBTree import OOBTree
#h_depth_2 = OOBTree()
for i in xrange(%d / 100):
for j in xrange(100):
id = "-".join(map(str,(i,j)))
h_depth_2[id] = File(id)
"""
)
init_3
=
dedent
(
"""
from Products.HBTreeFolder2.HBTreeFolder2 import HBTreeFolder2
from Products.CMFDefault.File import File
h_depth_3 = HBTreeFolder2()
#from BTrees.OOBTree import OOBTree
#h_depth_3 = OOBTree()
for i in xrange(%d / (100 * 10)):
for j in xrange(100):
for k in xrange(10):
id = "-".join(map(str, (i, j, k)))
h_depth_3[id] = File(id)
"""
)
N
=
1000
# measure 100 times of each test
t1
=
timeit
.
Timer
(
"h_depth_1['555']"
,
init_1
%
N
).
timeit
(
100
)
t2
=
timeit
.
Timer
(
"h_depth_2['5-55']"
,
init_2
%
N
).
timeit
(
100
)
t3
=
timeit
.
Timer
(
"h_depth_3['0-55-5']"
,
init_3
%
N
).
timeit
(
100
)
ZopeTestCase
.
_print
(
"
\
n
N = 1000
\
n
"
)
ZopeTestCase
.
_print
(
"L1=%s
\
t
L2=%s
\
t
L3=%s"
%
(
t1
,
t2
,
t3
))
N
=
10000
# 10 times bigger than previous test
# measure 100 times of each test
t2_1
=
timeit
.
Timer
(
"h_depth_1['5555']"
,
init_1
%
N
).
timeit
(
100
)
t2_2
=
timeit
.
Timer
(
"h_depth_2['55-55']"
,
init_2
%
N
).
timeit
(
100
)
t2_3
=
timeit
.
Timer
(
"h_depth_3['5-55-5']"
,
init_3
%
N
).
timeit
(
100
)
ZopeTestCase
.
_print
(
"
\
n
N = 10000
\
n
"
)
ZopeTestCase
.
_print
(
"L1'=%s
\
t
L2'=%s
\
t
L3'=%s"
%
(
t2_1
,
t2_2
,
t2_3
))
N
=
100000
# 10 times bigger than pevious test
t3_1
=
timeit
.
Timer
(
"h_depth_1['22222']"
,
init_1
%
N
).
timeit
(
100
)
t3_2
=
timeit
.
Timer
(
"h_depth_2['222-22']"
,
init_2
%
N
).
timeit
(
100
)
t3_3
=
timeit
.
Timer
(
"h_depth_3['22-22-2']"
,
init_3
%
N
).
timeit
(
100
)
ZopeTestCase
.
_print
(
"
\
n
N = 100000
\
n
"
)
ZopeTestCase
.
_print
(
"L1''=%s
\
t
L2''=%s
\
t
L3''=%s"
%
(
t3_1
,
t3_2
,
t3_3
))
# These assert are should be True, but right now those are not passed
# assert that L2 is faster than L1, because the bottom node is smaller
self
.
assertTrue
(
t1
>
t2
)
self
.
assertTrue
(
t2_1
>
t2_2
)
self
.
assertTrue
(
t3_1
>
t3_2
)
# assert that L3 is faster than L2, because the bottom node is smaller
self
.
assertTrue
(
t2
>
t3
)
self
.
assertTrue
(
t2_2
>
t2_3
)
self
.
assertTrue
(
t3_2
>
t3_3
)
class
TrojanKey
:
"""Pretends to be a consistent, immutable, humble citizen...
...
...
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