Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dios
Manage
Activity
Members
Labels
Plan
Issues
11
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
0
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
RDM
dios
Commits
8144f3c4
Commit
8144f3c4
authored
5 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
dos->dios
parent
200b7aec
No related branches found
No related tags found
2 merge requests
!2
Develop
,
!1
complete rework
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
profiling/generate_testsets.py
+8
-13
8 additions, 13 deletions
profiling/generate_testsets.py
profiling/memory.py
+12
-12
12 additions, 12 deletions
profiling/memory.py
profiling/performance.py
+11
-11
11 additions, 11 deletions
profiling/performance.py
with
31 additions
and
36 deletions
profiling/generate_testsets.py
+
8
−
13
View file @
8144f3c4
...
...
@@ -44,14 +44,9 @@ def _gen_testset(rowsz, colsz, freq='1min', disalign=True, randstart=True):
return
df
,
dos
def
_gen_df
(
rowsz
,
colsz
,
freq
=
'
1min
'
,
disalign
=
True
,
randstart
=
True
):
df
,
_
=
_gen_testset
(
rowsz
=
rowsz
,
colsz
=
colsz
,
freq
=
freq
,
disalign
=
disalign
,
randstart
=
randstart
)
return
df
def
gen_dos
(
rowsz
,
colsz
,
freq
=
'
1min
'
,
disalign
=
True
,
randstart
=
True
):
_
,
dos
=
_gen_testset
(
rowsz
=
rowsz
,
colsz
=
colsz
,
freq
=
freq
,
disalign
=
disalign
,
randstart
=
randstart
)
return
dos
def
get_random_df_and_dios
(
rowsz
,
colsz
,
freq
=
'
1min
'
,
disalign
=
True
,
randstart
=
True
):
df
,
_
,
_
,
dios
,
*
_
=
get_testset
(
rowsz
,
colsz
,
freq
=
freq
,
disalign
=
disalign
,
randstart
=
randstart
)
return
df
,
dios
def
get_testset
(
rows
,
cols
,
freq
=
'
1s
'
,
disalign
=
True
,
randstart
=
True
,
storagedir
=
'
testsets
'
,
noresult
=
False
):
...
...
@@ -63,11 +58,11 @@ def get_testset(rows, cols, freq='1s', disalign=True, randstart=True, storagedir
return
tup
=
pickle
.
load
(
fh
)
except
(
pickle
.
UnpicklingError
,
FileNotFoundError
):
df
_
,
dos
_
=
_gen_testset
(
rowsz
=
rows
,
colsz
=
cols
,
freq
=
freq
,
disalign
=
disalign
,
randstart
=
randstart
)
df
_
=
df
_
.
sort_index
(
axis
=
0
,
level
=
0
)
a
_
=
df
_
.
copy
().
stack
(
dropna
=
False
).
sort_index
(
axis
=
0
,
level
=
0
).
copy
()
b
_
=
df
_
.
copy
().
unstack
().
sort_index
(
axis
=
0
,
level
=
0
).
copy
()
tup
=
df
_
,
a_
,
b_
,
dos
_
df
,
d
i
os
=
_gen_testset
(
rowsz
=
rows
,
colsz
=
cols
,
freq
=
freq
,
disalign
=
disalign
,
randstart
=
randstart
)
df
=
df
.
sort_index
(
axis
=
0
,
level
=
0
)
df_type_
a
=
df
.
copy
().
stack
(
dropna
=
False
).
sort_index
(
axis
=
0
,
level
=
0
).
copy
()
df_type_
b
=
df
.
copy
().
unstack
().
sort_index
(
axis
=
0
,
level
=
0
).
copy
()
tup
=
df
,
df_type_a
,
df_type_b
,
d
i
os
with
open
(
fpath
,
'
wb
'
)
as
fh
:
pickle
.
dump
(
tup
,
fh
)
...
...
This diff is collapsed.
Click to expand it.
profiling/memory.py
+
12
−
12
View file @
8144f3c4
import
gc
from
profiling
import
get_testset
,
_gen_testset
from
profiling
.generate_testsets
import
get_random_df_and_dios
def
calc_mem
(
rows
,
cols
,
shifted
=
False
,
dtypesz
=
(
64
/
8
)):
...
...
@@ -36,7 +36,7 @@ def rows_by_time(nsec, mdays):
if
__name__
==
'
__main__
'
:
# dos - linear in rows and colums, same size for r=10,c=100 or r=100,c=10
# d
i
os - linear in rows and colums, same size for r=10,c=100 or r=100,c=10
do_real_check
=
True
cols
=
10
rows
=
100000
...
...
@@ -45,14 +45,14 @@ if __name__ == '__main__':
mem
=
calc_mem
(
rows
,
cols
,
shifted
=
False
)
memsh
=
calc_mem
(
rows
,
cols
,
shifted
=
True
)
df
,
_
,
_
,
dos
=
get_
testset
(
rows
,
cols
,
disalign
=
False
,
randstart
=
True
)
dos_mem
=
dos
.
memory_usage
()
print
(
f
"
dos:
\n
-----------
"
)
print
(
"
mem:
"
,
*
bytes2hread
(
dos_mem
))
print
(
"
entries:
"
,
sum
([
len
(
dos
[
e
])
for
e
in
dos
]))
df
,
d
i
os
=
get_
random_df_and_dios
(
rows
,
cols
,
disalign
=
False
,
randstart
=
True
)
d
i
os_mem
=
d
i
os
.
memory_usage
()
print
(
f
"
d
i
os:
\n
-----------
"
)
print
(
"
mem:
"
,
*
bytes2hread
(
d
i
os_mem
))
print
(
"
entries:
"
,
sum
([
len
(
d
i
os
[
e
])
for
e
in
d
i
os
]))
print
()
ratio
=
(
1
/
(
memsh
-
mem
)
)
*
dos_mem
ratio
=
(
1
/
(
memsh
-
mem
)
)
*
d
i
os_mem
mem
=
bytes2hread
(
mem
)
memsh
=
bytes2hread
(
memsh
)
...
...
@@ -66,7 +66,7 @@ if __name__ == '__main__':
print
(
"
entries:
"
,
rows
*
cols
)
print
()
print
(
f
"
dfbest, dos, dfworst: 0%,
{
round
(
ratio
,
4
)
*
100
}
%, 100%
"
)
print
(
f
"
dfbest, d
i
os, dfworst: 0%,
{
round
(
ratio
,
4
)
*
100
}
%, 100%
"
)
if
not
do_real_check
:
exit
(
0
)
...
...
@@ -77,7 +77,7 @@ if __name__ == '__main__':
# best case
print
()
print
(
'
best case proove
'
)
dfb
,
_
=
_
ge
n_testset
(
rows
,
cols
,
disalign
=
False
,
randstart
=
False
)
dfb
,
_
=
ge
t_random_df_and_dios
(
rows
,
cols
,
disalign
=
False
,
randstart
=
False
)
dfb
.
info
(
memory_usage
=
'
deep
'
,
verbose
=
False
)
print
()
...
...
@@ -87,7 +87,7 @@ if __name__ == '__main__':
print
()
print
(
'
rand start, rand freq
'
)
df
,
_
=
get_
testset
(
rows
,
cols
,
disalign
=
'
random
'
,
randstart
=
True
)
df
,
_
=
get_
random_df_and_dios
(
rows
,
cols
,
disalign
=
'
random
'
,
randstart
=
True
)
df
.
info
(
memory_usage
=
'
deep
'
,
verbose
=
False
)
print
(
"
entries:
"
,
sum
([
len
(
df
[
e
])
for
e
in
df
]))
...
...
@@ -95,7 +95,7 @@ if __name__ == '__main__':
# worst case
print
()
print
(
'
worst case proove
'
)
df
,
_
=
_
ge
n_testset
(
rows
,
cols
,
disalign
=
True
,
randstart
=
False
)
df
,
_
=
ge
t_random_df_and_dios
(
rows
,
cols
,
disalign
=
True
,
randstart
=
False
)
df
.
info
(
memory_usage
=
'
deep
'
,
verbose
=
False
)
gc
.
collect
()
This diff is collapsed.
Click to expand it.
profiling/performance.py
+
11
−
11
View file @
8144f3c4
import
pandas
as
pd
import
numpy
as
np
import
time
from
profiling
import
get_testset
,
var_prefix
from
profiling
.generate_testsets
import
get_testset
,
var_prefix
profile_assignment
=
False
...
...
@@ -61,20 +61,20 @@ def b_timings(df, t0, t1, v1, v2):
return
a
,
b
,
df
def
dos_timings
(
dos
,
t0
,
t1
,
v1
,
v2
):
def
d
i
os_timings
(
d
i
os
,
t0
,
t1
,
v1
,
v2
):
_t0
=
time
.
time
()
a
=
dos
[
t0
:
t1
,
:]
a
=
d
i
os
[
t0
:
t1
,
:]
_t1
=
time
.
time
()
b
=
dos
[:,
v1
]
b
=
d
i
os
[:,
v1
]
_t2
=
time
.
time
()
if
profile_assignment
:
dos
[
t0
:
t1
,
v1
]
=
dos
[
t0
:
t1
,
v1
]
*
1111
d
i
os
[
t0
:
t1
,
v1
]
=
d
i
os
[
t0
:
t1
,
v1
]
*
1111
_t3
=
time
.
time
()
timingsdf
.
at
[
rows
,
(
'
ts
'
,
'
dios
'
)]
+=
_t1
-
_t0
timingsdf
.
at
[
rows
,
(
'
var
'
,
'
dios
'
)]
+=
_t2
-
_t1
timingsdf
.
at
[
rows
,
(
'
ass
'
,
'
dios
'
)]
+=
_t3
-
_t2
return
a
,
b
,
dos
return
a
,
b
,
d
i
os
def
gen_random_timestamps
(
m
,
M
):
...
...
@@ -116,7 +116,7 @@ if __name__ == '__main__':
use_df
=
True
use_a
=
False
use_b
=
False
use_dos
=
True
use_d
i
os
=
True
# plot options
normalize_to_df
=
False
...
...
@@ -132,7 +132,7 @@ if __name__ == '__main__':
timingsdf
.
loc
[
rows
]
=
(
0
,)
*
len
(
timingsdf
.
columns
)
df
,
a
,
b
,
dos
=
get_testset
(
rows
,
cols
)
df
,
a
,
b
,
d
i
os
=
get_testset
(
rows
,
cols
)
t0
,
t4
=
find_index_range
(
df
)
if
use_df
or
normalize_to_df
:
...
...
@@ -153,11 +153,11 @@ if __name__ == '__main__':
vr1
=
var_prefix
+
str
(
np
.
random
.
randint
(
0
,
cols
))
b_timings
(
b
,
t1
,
t2
,
vr1
,
None
)
if
use_dos
:
if
use_d
i
os
:
for
r
in
range
(
runs
):
t1
,
t2
=
gen_random_timestamps
(
t0
,
t4
)
vr1
=
var_prefix
+
str
(
np
.
random
.
randint
(
0
,
cols
))
dos_timings
(
dos
,
t1
,
t2
,
vr1
,
None
)
d
i
os_timings
(
d
i
os
,
t1
,
t2
,
vr1
,
None
)
# calc the average
timingsdf
/=
runs
...
...
@@ -198,7 +198,7 @@ if __name__ == '__main__':
a
.
plot
(
logy
=
plot_ylog
,
logx
=
plot_xlog
,
linestyle
=
'
--
'
,
ax
=
ax
)
if
use_b
:
b
.
plot
(
logy
=
plot_ylog
,
logx
=
plot_xlog
,
linestyle
=
'
:
'
,
ax
=
ax
)
if
use_dos
:
if
use_d
i
os
:
dios
.
plot
(
logy
=
plot_ylog
,
logx
=
plot_xlog
,
linestyle
=
'
-.
'
,
ax
=
ax
)
plt
.
show
()
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