Performance Test for Clone Protocol¶
see sage.structure.list_clone.ClonableArray
EXAMPLES:
sage: from sage.structure.list_clone_timings import *
sage: cmd =["",
....: "e.__copy__()",
....: "copy(e)",
....: "e.clone()",
....: "e.__class__(e.parent(), e._get_list())",
....: "e.__class__(e.parent(), e[:])",
....: "e.check()",
....: "",
....: "add1_internal(e)",
....: "add1_immutable(e)",
....: "add1_mutable(e)",
....: "add1_with(e)",
....: "",
....: "cy_add1_internal(e)",
....: "cy_add1_immutable(e)",
....: "cy_add1_mutable(e)",
....: "cy_add1_with(e)"]
Various timings using a Cython class:
sage: size = 5
sage: e = IncreasingArrays()(range(size))
sage: # random
....: for p in cmd:
....: print("{0:36} : ".format(p), end=""); timeit(p)
:
e.__copy__() : 625 loops, best of 3: 446 ns per loop
copy(e) : 625 loops, best of 3: 1.94 µs per loop
e.clone() : 625 loops, best of 3: 736 ns per loop
e.__class__(e.parent(), e._get_list()) : 625 loops, best of 3: 1.34 µs per loop
e.__class__(e.parent(), e[:]) : 625 loops, best of 3: 1.35 µs per loop
e.check() : 625 loops, best of 3: 342 ns per loop
:
add1_internal(e) : 625 loops, best of 3: 3.53 µs per loop
add1_immutable(e) : 625 loops, best of 3: 3.72 µs per loop
add1_mutable(e) : 625 loops, best of 3: 3.42 µs per loop
add1_with(e) : 625 loops, best of 3: 4.05 µs per loop
:
cy_add1_internal(e) : 625 loops, best of 3: 752 ns per loop
cy_add1_immutable(e) : 625 loops, best of 3: 1.28 µs per loop
cy_add1_mutable(e) : 625 loops, best of 3: 861 ns per loop
cy_add1_with(e) : 625 loops, best of 3: 1.51 µs per loop
Various timings using a Python class:
sage: e = IncreasingArraysPy()(range(size))
sage: # random
....: for p in cmd: print("{0:36} : ".format(p), end=""); timeit(p)
:
e.__copy__() : 625 loops, best of 3: 869 ns per loop
copy(e) : 625 loops, best of 3: 2.13 µs per loop
e.clone() : 625 loops, best of 3: 1.86 µs per loop
e.__class__(e.parent(), e._get_list()) : 625 loops, best of 3: 7.52 µs per loop
e.__class__(e.parent(), e[:]) : 625 loops, best of 3: 7.27 µs per loop
e.check() : 625 loops, best of 3: 4.02 µs per loop
:
add1_internal(e) : 625 loops, best of 3: 9.34 µs per loop
add1_immutable(e) : 625 loops, best of 3: 9.91 µs per loop
add1_mutable(e) : 625 loops, best of 3: 12.6 µs per loop
add1_with(e) : 625 loops, best of 3: 15.9 µs per loop
:
cy_add1_internal(e) : 625 loops, best of 3: 7.13 µs per loop
cy_add1_immutable(e) : 625 loops, best of 3: 6.95 µs per loop
cy_add1_mutable(e) : 625 loops, best of 3: 14.1 µs per loop
cy_add1_with(e) : 625 loops, best of 3: 17.5 µs per loop
-
class
sage.structure.list_clone_timings.
IncreasingArraysPy
¶ Bases:
sage.structure.list_clone_demo.IncreasingArrays
-
class
Element
¶ Bases:
sage.structure.list_clone.ClonableArray
A small class for testing
ClonableArray
: Increasing Lists-
check
()¶ Check that
self
is increasing.EXAMPLES:
sage: from sage.structure.list_clone_timings import IncreasingArraysPy sage: IncreasingArraysPy()([1,2,3]) # indirect doctest [1, 2, 3] sage: IncreasingArraysPy()([3,2,1]) # indirect doctest Traceback (most recent call last): ... ValueError: Lists is not increasing
-
-
class
-
sage.structure.list_clone_timings.
add1_immutable
(bla)¶
-
sage.structure.list_clone_timings.
add1_internal
(bla)¶
-
sage.structure.list_clone_timings.
add1_mutable
(bla)¶
-
sage.structure.list_clone_timings.
add1_with
(bla)¶