You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by cj...@apache.org on 2018/03/14 17:21:33 UTC
[incubator-mxnet] 07/10: cython timing tests
This is an automated email from the ASF dual-hosted git repository.
cjolivier01 pushed a commit to branch cython
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
commit 809bdecf80a62b4d1f191408b7f7a35fe807dcb6
Author: Olivier <co...@amazon.com>
AuthorDate: Fri Mar 9 09:00:21 2018 -0800
cython timing tests
---
python/mxnet/cython/mxcython.pyx | 10 +++++++---
tests/python/unittest/test_cython.py | 36 +++++++++++++++++++++---------------
tools/cython/cydb2 | 2 +-
tools/cython/cydb3 | 2 +-
4 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/python/mxnet/cython/mxcython.pyx b/python/mxnet/cython/mxcython.pyx
index ed3601d..914de61 100644
--- a/python/mxnet/cython/mxcython.pyx
+++ b/python/mxnet/cython/mxcython.pyx
@@ -86,9 +86,13 @@ def test_perf(int count, int make_c_call):
msg = " WITH API CALL"
Printf("CYTHON %s: %d items took %f seconds\n", msg, count, float(stop - start)/1000)
-def bridge_c_call(int value, int make_c_call):
- if make_c_call != 0:
- return TrivialCPPCall(value)
+def bridge_c_call(int value, int api_call_count):
+ cdef int v = value
+ cdef int acc = api_call_count
+ cdef int x = 0
+ while x < acc:
+ TrivialCPPCall(v)
+ x += 1
def print_pi(terms):
print(float(0.0))
diff --git a/tests/python/unittest/test_cython.py b/tests/python/unittest/test_cython.py
index 7b6e9e1..0e4959e 100644
--- a/tests/python/unittest/test_cython.py
+++ b/tests/python/unittest/test_cython.py
@@ -69,8 +69,10 @@ def test_perf(count, make_c_call):
msg = " WITH API CALL"
print("PYTHON {}: {} items took {} seconds".format(msg, count, float(stop - start)/1000))
-def test_perf_bridge(count, make_c_call):
- mcc = int(make_c_call)
+def test_perf_bridge(count, do_cython_call, api_call_count):
+ if do_cython_call == 0:
+ assert api_call_count == 0 # Sanity on input values
+ acc = int(api_call_count)
start = _LIB.TimeInMilliseconds()
foo = 0
i = 0
@@ -78,26 +80,30 @@ def test_perf_bridge(count, make_c_call):
foo += i
if foo > count:
foo = 0
- if make_c_call != 0:
- mxc.bridge_c_call(0, mcc)
+ if do_cython_call != 0:
+ mxc.bridge_c_call(0, acc)
i += 1
stop = _LIB.TimeInMilliseconds()
msg = ""
- if make_c_call != 0:
- msg = " WITH API CALL"
- print("PYTHON->CYTHON BRIDGE {}: {} items took {} seconds".format(msg, count, float(stop - start)/1000))
+ if do_cython_call != 0:
+ msg = " WITH CYTHON CALL"
+ else:
+ msg = " WITHOUT CYTHON CALL"
+ print("PYTHON->CYTHON BRIDGE {}, ACC={}: {} items took {} seconds".format(
+ msg, acc, count, float(stop - start)/1000))
if __name__ == '__main__':
# import nose
# nose.runmodule()
- # iter_count = 100000000
- # test_perf(iter_count, 0)
- # mxc.test_perf(iter_count, 0)
- # test_perf(iter_count, 1)
- # mxc.test_perf(iter_count, 1)
- # test_perf_bridge(iter_count, 0)
- # test_perf_bridge(iter_count, 1)
+ iter_count = 100000000
+ test_perf(iter_count, 0)
+ mxc.test_perf(iter_count, 0)
+ test_perf(iter_count, 1)
+ mxc.test_perf(iter_count, 1)
+ test_perf_bridge(iter_count, 0, 0)
+ test_perf_bridge(iter_count, 1, 0)
+ test_perf_bridge(iter_count, 1, 10)
- test_basic_cython()
+# test_basic_cython()
diff --git a/tools/cython/cydb2 b/tools/cython/cydb2
index 5157a26..cafe054 100755
--- a/tools/cython/cydb2
+++ b/tools/cython/cydb2
@@ -23,5 +23,5 @@ if [ -d ../../cmake-build-debug/mxnet/cython/cy2 ]; then
elif [ -d ../cmake-build-debug/mxnet/cython/cy2 ]; then
cygdb ../cmake-build-debug/mxnet/cython/cy2 -- $@
else
- echo "$0: Don't know where to find cythoin debug info"
+ echo "$0: Don't know where to find cython debug info"
fi
diff --git a/tools/cython/cydb3 b/tools/cython/cydb3
index 62a346a..5762943 100755
--- a/tools/cython/cydb3
+++ b/tools/cython/cydb3
@@ -23,5 +23,5 @@ if [ -d ../../cmake-build-debug/mxnet/cython/cy3 ]; then
elif [ -d ../cmake-build-debug/mxnet/cython/cy3 ]; then
cygdb ../cmake-build-debug/mxnet/cython/cy3 -- $@
else
- echo "$0: Don't know where to find cythoin debug info"
+ echo "$0: Don't know where to find cython debug info"
fi
--
To stop receiving notification emails like this one, please contact
cjolivier01@apache.org.