Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
NumerikGang
curvepy
Commits
40dea6bb
Commit
40dea6bb
authored
May 30, 2022
by
timo.specht
Browse files
🍱
Benchmarks Added
parent
30947a18
Changes
1
Hide whitespace changes
Inline
Side-by-side
curvepy/curves_benchmark.py
0 → 100644
View file @
40dea6bb
import
cProfile
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
random
import
timeit
from
curvepy.bezier_curve
import
*
def
gen_pts
(
n
=
12
):
xs
,
ys
=
[
random
.
random
()
*
40
-
20
for
_
in
range
(
n
)],
[
random
.
random
()
*
40
-
20
for
_
in
range
(
n
)]
return
np
.
array
([
xs
,
ys
])
def
main
(
start
,
end
,
step
):
curves
=
[
BezierCurveMonomial
]
# BezierCurveDeCaes, BezierCurveBernstein, BezierCurveHorner, BezierCurveApproximation
points
=
{
c
:
[]
for
c
in
curves
}
print
(
"hello"
)
for
cnt_p
in
range
(
start
,
end
,
step
):
print
(
"hello"
)
times
=
{
c
:
[]
for
c
in
curves
}
for
_
in
range
(
1
):
pts
=
gen_pts
(
n
=
cnt_p
)
for
c
in
curves
:
b
=
c
(
pts
)
t
=
timeit
.
timeit
(
'b.curve'
,
globals
=
locals
())
times
[
c
].
append
(
t
)
for
c
in
curves
:
points
[
c
].
append
((
cnt_p
,
sum
(
times
[
c
])
/
len
(
times
[
c
])))
for
c
in
curves
:
plt
.
plot
([
x
[
0
]
for
x
in
points
[
c
]],
[
x
[
1
]
for
x
in
points
[
c
]])
plt
.
legend
([
c
for
c
in
curves
])
plt
.
show
()
if
__name__
==
'__main__'
:
main
(
start
=
1
,
end
=
1000
,
step
=
50
)
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