Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
erp5
Commits
c87cf495
Commit
c87cf495
authored
Sep 06, 2011
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to specify the repeat for a range of users
parent
35eb6972
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
19 deletions
+61
-19
erp5/util/benchmark/performance_tester.py
erp5/util/benchmark/performance_tester.py
+41
-12
erp5/util/benchmark/process.py
erp5/util/benchmark/process.py
+5
-2
erp5/util/benchmark/result.py
erp5/util/benchmark/result.py
+15
-5
No files found.
erp5/util/benchmark/performance_tester.py
View file @
c87cf495
...
...
@@ -108,8 +108,15 @@ class PerformanceTester(object):
type
=
ArgumentType
.
checkIntValueWrapper
(
minimum
=
1
),
default
=-
1
,
metavar
=
'N'
,
help
=
'Repeat the benchmark suite N times '
'(default: infinite)'
)
help
=
'Repeat the benchmark suite N times for a given '
'number of users (default: infinite)'
)
parser
.
add_argument
(
'--repeat-range'
,
type
=
ArgumentType
.
checkIntValueWrapper
(
minimum
=
1
),
default
=-
1
,
metavar
=
'N'
,
help
=
'Repeat the benchmark suite N times for the whole '
'range of users (default: infinite)'
)
parser
.
add_argument
(
'--user-index'
,
type
=
int
,
...
...
@@ -158,6 +165,10 @@ class PerformanceTester(object):
min
(
len
(
namespace
.
benchmark_suite_list
)
*
namespace
.
repeat
,
namespace
.
max_error_number
)
if
isinstance
(
namespace
.
users
,
tuple
)
and
namespace
.
repeat
==
-
1
:
raise
argparse
.
ArgumentTypeError
(
"Repeat cannot be infinite for a "
"range of users"
)
namespace
.
benchmark_suite_name_list
=
namespace
.
benchmark_suite_list
namespace
.
benchmark_suite_list
=
object_benchmark_suite_list
...
...
@@ -205,7 +216,7 @@ class PerformanceTester(object):
ERP5BenchmarkResult
.
closeResultDocument
(
self
.
_argument_namespace
.
erp5_publish_url
,
error_message_set
)
def
_run_constant
(
self
,
nb_users
):
def
_run_constant
(
self
,
nb_users
,
current_repeat_range
=
None
):
process_list
=
[]
exit_msg_queue
=
multiprocessing
.
Queue
(
nb_users
)
...
...
@@ -214,7 +225,8 @@ class PerformanceTester(object):
for
user_index
in
range
(
nb_users
):
process
=
BenchmarkProcess
(
exit_msg_queue
,
result_class
,
self
.
_argument_namespace
,
nb_users
,
user_index
)
user_index
,
current_repeat_range
)
process_list
.
append
(
process
)
...
...
@@ -269,14 +281,31 @@ class PerformanceTester(object):
self
.
preRun
()
if
isinstance
(
self
.
_argument_namespace
.
users
,
tuple
):
nb_users
,
max_users
=
self
.
_argument_namespace
.
users
min_user_number
,
max_user_number
=
self
.
_argument_namespace
.
users
repeat_counter
=
0
exit_with_error
=
False
while
(
repeat_counter
!=
self
.
_argument_namespace
.
repeat_range
and
not
exit_with_error
):
current_user_number
=
min_user_number
while
True
:
error_message_set
,
exit_status
=
self
.
_run_constant
(
nb_users
)
if
exit_status
!=
0
or
nb_users
==
max_users
:
error_message_set
,
exit_status
=
\
self
.
_run_constant
(
current_user_number
,
repeat_counter
)
if
exit_status
!=
0
:
exit_with_error
=
True
break
elif
current_user_number
==
max_user_number
:
break
nb_users
=
min
(
nb_users
+
self
.
_argument_namespace
.
users_range_increment
,
max_users
)
current_user_number
=
\
min
((
current_user_number
+
self
.
_argument_namespace
.
users_range_increment
),
max_user_number
)
repeat_counter
+=
1
else
:
error_message_set
,
exit_status
=
self
.
_run_constant
(
self
.
_argument_namespace
.
users
)
...
...
erp5/util/benchmark/process.py
View file @
c87cf495
...
...
@@ -43,12 +43,14 @@ RESULT_NUMBER_BEFORE_FLUSHING = 100
class
BenchmarkProcess
(
multiprocessing
.
Process
):
def
__init__
(
self
,
exit_msg_queue
,
result_klass
,
argument_namespace
,
nb_users
,
user_index
,
*
args
,
**
kwargs
):
nb_users
,
user_index
,
current_repeat_range
,
*
args
,
**
kwargs
):
self
.
_exit_msg_queue
=
exit_msg_queue
self
.
_result_klass
=
result_klass
self
.
_argument_namespace
=
argument_namespace
self
.
_nb_users
=
nb_users
self
.
_user_index
=
user_index
self
.
_current_repeat_range
=
current_repeat_range
self
.
_base_url
,
self
.
_erp5_site_id
=
argument_namespace
.
url
try
:
...
...
@@ -137,7 +139,8 @@ class BenchmarkProcess(multiprocessing.Process):
def
run
(
self
):
result_instance
=
self
.
_result_klass
(
self
.
_argument_namespace
,
self
.
_nb_users
,
self
.
_user_index
)
self
.
_user_index
,
self
.
_current_repeat_range
)
self
.
_logger
=
result_instance
.
logger
...
...
erp5/util/benchmark/result.py
View file @
c87cf495
...
...
@@ -81,10 +81,13 @@ import abc
class
BenchmarkResult
(
object
):
__metaclass__
=
abc
.
ABCMeta
def
__init__
(
self
,
argument_namespace
,
nb_users
,
user_index
):
def
__init__
(
self
,
argument_namespace
,
nb_users
,
user_index
,
current_repeat_range
):
self
.
_argument_namespace
=
argument_namespace
self
.
_nb_users
=
nb_users
self
.
_user_index
=
user_index
self
.
_current_repeat_range
=
current_repeat_range
self
.
_logger
=
None
self
.
_label_list
=
None
...
...
@@ -229,11 +232,18 @@ class CSVBenchmarkResult(BenchmarkResult):
self
.
log_file
=
open
(
self
.
_log_filename_path
,
'w'
)
def
_getFilenamePrefix
(
self
):
max_nb_users
=
isinstance
(
self
.
_argument_namespace
.
users
,
int
)
and
\
self
.
_argument_namespace
.
users
or
self
.
_argument_namespace
.
users
[
1
]
if
isinstance
(
self
.
_argument_namespace
.
users
,
int
):
max_nb_users
=
self
.
_argument_namespace
.
users
suffix
=
''
else
:
max_nb_users
=
self
.
_argument_namespace
.
users
[
1
]
suffix
=
'-rrepeat%%0%dd'
%
len
(
str
(
self
.
_argument_namespace
.
repeat_range
))
suffix
=
suffix
%
self
.
_current_repeat_range
fmt
=
"%%s-%%drepeat-%%0%ddusers-process%%0%dd"
%
\
(
len
(
str
(
max_nb_users
)),
len
(
str
(
self
.
_nb_users
)))
fmt
=
"%%s-%%drepeat-%%0%ddusers-process%%0%dd%s"
%
\
(
len
(
str
(
max_nb_users
)),
len
(
str
(
self
.
_nb_users
)),
suffix
)
return
fmt
%
(
self
.
_argument_namespace
.
filename_prefix
,
self
.
_argument_namespace
.
repeat
,
...
...
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