Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
scmperf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mercurial
scmperf
Commits
9ccddb7e330b
Commit
9ccddb7e330b
authored
7 years ago
by
Boris Feld
Browse files
Options
Downloads
Patches
Plain Diff
exchange: store tar cache in repos/.cache
Also extract clone test in their own class to avoid cloning several times
parent
d99e66b6e060
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
benchmarks/basic_commands.py
+74
-68
74 additions, 68 deletions
benchmarks/basic_commands.py
with
74 additions
and
68 deletions
benchmarks/basic_commands.py
+
74
−
68
View file @
9ccddb7e
...
@@ -138,6 +138,6 @@
...
@@ -138,6 +138,6 @@
class
ExchangeTrackSuite
(
BaseTrackTestSuite
):
class
ExchangeTrackSuite
(
BaseTrackTestSuite
):
param_names
=
BaseTrackTestSuite
.
param_names
+
[
'
single_rev
'
,
'
revset
'
]
param_names
=
BaseTrackTestSuite
.
param_names
+
[
'
revset
'
]
params
=
BaseTrackTestSuite
.
params
+
[[
True
,
False
]]
+
[[
'
default~10
'
]]
params
=
BaseTrackTestSuite
.
params
+
[[
'
default~10
'
,
None
]]
...
@@ -143,4 +143,4 @@
...
@@ -143,4 +143,4 @@
def
setup
(
self
,
repo_name
,
single_rev
,
revset
,
*
args
,
**
kwargs
):
def
setup
(
self
,
repo_name
,
revset
,
*
args
,
**
kwargs
):
super
(
ExchangeTrackSuite
,
self
).
setup
(
repo_name
,
*
args
,
**
kwargs
)
super
(
ExchangeTrackSuite
,
self
).
setup
(
repo_name
,
*
args
,
**
kwargs
)
...
@@ -145,6 +145,8 @@
...
@@ -145,6 +145,8 @@
super
(
ExchangeTrackSuite
,
self
).
setup
(
repo_name
,
*
args
,
**
kwargs
)
super
(
ExchangeTrackSuite
,
self
).
setup
(
repo_name
,
*
args
,
**
kwargs
)
self
.
single_rev
=
single_rev
self
.
revset
=
revset
self
.
cachedir
=
os
.
path
.
join
(
REPOS_DIR
,
'
.cache
'
)
from
base64
import
b64encode
from
base64
import
b64encode
...
@@ -148,6 +150,4 @@
...
@@ -148,6 +150,4 @@
from
base64
import
b64encode
from
base64
import
b64encode
self
.
safe_range
=
b64encode
(
revset
)
self
.
tempdir
=
tempfile
.
mkdtemp
(
dir
=
os
.
environ
.
get
(
'
ASVTEMPDIR
'
))
...
@@ -153,3 +153,3 @@
...
@@ -153,3 +153,3 @@
if
single_rev
is
Fals
e
:
if
revset
is
Non
e
:
self
.
cache_name
=
"
%s.tar
"
%
repo_name
self
.
cache_name
=
"
%s.tar
"
%
repo_name
...
@@ -155,7 +155,7 @@
...
@@ -155,7 +155,7 @@
self
.
cache_name
=
"
%s.tar
"
%
repo_name
self
.
cache_name
=
"
%s.tar
"
%
repo_name
self
.
cache_path
=
os
.
path
.
join
(
self
.
temp
dir
,
self
.
cache_name
)
self
.
cache_path
=
os
.
path
.
join
(
self
.
cache
dir
,
self
.
cache_name
)
if
not
os
.
path
.
isfile
(
self
.
cache_path
):
if
not
os
.
path
.
isfile
(
self
.
cache_path
):
tar_cmd
=
"
tar cf %s -C %s .
"
%
(
self
.
cache_path
,
self
.
repo_path
)
tar_cmd
=
"
tar cf %s -C %s .
"
%
(
self
.
cache_path
,
self
.
repo_path
)
self
.
_single_execute
(
shlex
.
split
(
tar_cmd
))
self
.
_single_execute
(
shlex
.
split
(
tar_cmd
))
else
:
else
:
...
@@ -157,10 +157,11 @@
...
@@ -157,10 +157,11 @@
if
not
os
.
path
.
isfile
(
self
.
cache_path
):
if
not
os
.
path
.
isfile
(
self
.
cache_path
):
tar_cmd
=
"
tar cf %s -C %s .
"
%
(
self
.
cache_path
,
self
.
repo_path
)
tar_cmd
=
"
tar cf %s -C %s .
"
%
(
self
.
cache_path
,
self
.
repo_path
)
self
.
_single_execute
(
shlex
.
split
(
tar_cmd
))
self
.
_single_execute
(
shlex
.
split
(
tar_cmd
))
else
:
else
:
self
.
cache_name
=
"
%s-%s-%s.tar
"
%
(
repo_name
,
single_rev
,
self
.
safe_range
)
safe_range
=
b64encode
(
revset
)
self
.
cache_path
=
os
.
path
.
join
(
self
.
tempdir
,
self
.
cache_name
)
self
.
cache_name
=
"
%s-%s.tar
"
%
(
repo_name
,
safe_range
)
self
.
cache_path
=
os
.
path
.
join
(
self
.
cachedir
,
self
.
cache_name
)
if
not
os
.
path
.
isfile
(
self
.
cache_path
):
if
not
os
.
path
.
isfile
(
self
.
cache_path
):
# First clone it
# First clone it
...
@@ -164,7 +165,7 @@
...
@@ -164,7 +165,7 @@
if
not
os
.
path
.
isfile
(
self
.
cache_path
):
if
not
os
.
path
.
isfile
(
self
.
cache_path
):
# First clone it
# First clone it
clone_path
=
os
.
path
.
join
(
self
.
temp
dir
,
"
%s-%s-clone
"
%
(
repo_name
,
self
.
safe_range
))
clone_path
=
os
.
path
.
join
(
self
.
cache
dir
,
"
%s-%s-clone
"
%
(
repo_name
,
safe_range
))
rev
=
self
.
_identify_id
(
revset
)
rev
=
self
.
_identify_id
(
revset
)
...
@@ -178,5 +179,11 @@
...
@@ -178,5 +179,11 @@
shutil
.
rmtree
(
clone_path
)
shutil
.
rmtree
(
clone_path
)
def
teardown
(
self
,
*
args
,
**
kwargs
):
def
_identify_id
(
self
,
revset
):
rev
=
subprocess
.
check_output
([
self
.
hgpath
,
'
--cwd
'
,
self
.
repo_path
,
'
identify
'
,
'
-i
'
,
"
-r
"
,
revset
],
env
=
self
.
environ
)
return
rev
.
strip
()
@contextlib.contextmanager
def
clone_from_cache
(
self
):
try
:
try
:
...
@@ -182,7 +189,59 @@
...
@@ -182,7 +189,59 @@
try
:
try
:
shutil
.
rmtree
(
self
.
tempdir
)
import
time
except
Exception
:
clone_path
=
os
.
path
.
join
(
self
.
cachedir
,
'
clone-%s
'
%
time
.
time
())
pass
os
.
mkdir
(
clone_path
)
cmd
=
"
tar xf %s -C %s
"
%
(
self
.
cache_path
,
clone_path
)
clone_time
=
self
.
_single_execute
(
shlex
.
split
(
cmd
))
yield
clone_path
finally
:
shutil
.
rmtree
(
clone_path
)
def
track_incoming
(
self
,
repo_name
,
revset
):
with
self
.
clone_from_cache
()
as
clone_path
:
cmd
=
[
self
.
hgpath
,
'
--cwd
'
,
clone_path
,
'
incoming
'
,
self
.
repo_path
]
if
revset
:
cmd
.
extend
([
'
-r
'
,
'
default
'
])
# Ignore the return code
return
self
.
_timeit
(
self
.
_single_execute
,
(
cmd
,
False
))
def
track_outgoing
(
self
,
repo_name
,
revset
):
with
self
.
clone_from_cache
()
as
clone_path
:
cmd
=
[
self
.
hgpath
,
'
--cwd
'
,
self
.
repo_path
,
'
outgoing
'
,
clone_path
]
if
revset
:
cmd
.
extend
([
'
-r
'
,
'
default
'
])
# Ignore the return code
return
self
.
_timeit
(
self
.
_single_execute
,
(
cmd
,
False
))
def
track_push
(
self
,
repo_name
,
revset
):
def
clone_and_push
():
with
self
.
clone_from_cache
()
as
clone_path
:
cmd
=
[
self
.
hgpath
,
'
--cwd
'
,
self
.
repo_path
,
'
push
'
,
'
-f
'
,
clone_path
]
if
revset
:
cmd
.
extend
([
'
-r
'
,
'
default
'
])
return
self
.
_single_execute
(
cmd
,
False
)
return
self
.
_timeit
(
clone_and_push
)
class
CloneTrackSuite
(
BaseTrackTestSuite
):
param_names
=
BaseTrackTestSuite
.
param_names
+
[
'
single_rev
'
,
'
revset
'
]
params
=
BaseTrackTestSuite
.
params
+
[[
True
,
False
]]
+
[[
'
default~10
'
]]
def
track_clone
(
self
,
repo_name
,
single_rev
,
revset
):
revset
=
'
default
'
if
single_rev
else
None
def
clone
():
with
self
.
clone
(
revset
=
revset
)
as
(
_
,
clone_time
):
return
clone_time
return
self
.
_timeit
(
clone
)
def
_identify_id
(
self
,
revset
):
def
_identify_id
(
self
,
revset
):
rev
=
subprocess
.
check_output
([
rev
=
subprocess
.
check_output
([
...
@@ -202,56 +261,3 @@
...
@@ -202,56 +261,3 @@
yield
clone_path
,
clone_time
yield
clone_path
,
clone_time
finally
:
finally
:
shutil
.
rmtree
(
clone_path
)
shutil
.
rmtree
(
clone_path
)
@contextlib.contextmanager
def
clone_from_cache
(
self
):
try
:
import
time
clone_path
=
os
.
path
.
join
(
self
.
tempdir
,
'
clone-%s
'
%
time
.
time
())
os
.
mkdir
(
clone_path
)
cmd
=
"
tar xf %s -C %s
"
%
(
self
.
cache_path
,
clone_path
)
clone_time
=
self
.
_single_execute
(
shlex
.
split
(
cmd
))
yield
clone_path
finally
:
shutil
.
rmtree
(
clone_path
)
def
track_incoming
(
self
,
repo_name
,
single_rev
,
revset
):
with
self
.
clone_from_cache
()
as
clone_path
:
cmd
=
[
self
.
hgpath
,
'
--cwd
'
,
clone_path
,
'
incoming
'
,
self
.
repo_path
]
if
single_rev
:
cmd
.
extend
([
'
-r
'
,
'
default
'
])
# Ignore the return code
return
self
.
_timeit
(
self
.
_single_execute
,
(
cmd
,
False
))
def
track_outgoing
(
self
,
repo_name
,
single_rev
,
revset
):
with
self
.
clone_from_cache
()
as
clone_path
:
cmd
=
[
self
.
hgpath
,
'
--cwd
'
,
self
.
repo_path
,
'
outgoing
'
,
clone_path
]
if
single_rev
:
cmd
.
extend
([
'
-r
'
,
'
default
'
])
# Ignore the return code
return
self
.
_timeit
(
self
.
_single_execute
,
(
cmd
,
False
))
def
track_push
(
self
,
repo_name
,
single_rev
,
revset
):
def
clone_and_push
():
with
self
.
clone_from_cache
()
as
clone_path
:
cmd
=
[
self
.
hgpath
,
'
--cwd
'
,
self
.
repo_path
,
'
push
'
,
'
-f
'
,
clone_path
]
if
single_rev
:
cmd
.
extend
([
'
-r
'
,
'
default
'
])
return
self
.
_single_execute
(
cmd
,
False
)
return
self
.
_timeit
(
clone_and_push
)
def
track_clone
(
self
,
repo_name
,
single_rev
,
revset
):
revset
=
'
default
'
if
single_rev
else
None
def
clone
():
with
self
.
clone
(
revset
=
revset
)
as
(
_
,
clone_time
):
return
clone_time
return
self
.
_timeit
(
clone
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment