From df6b5cfde15a6ae19145e9b545edb227f79a25e8 Mon Sep 17 00:00:00 2001 From: Bas van den Berg Date: Fri, 10 Jul 2015 19:40:10 +0200 Subject: [PATCH] Added string_equals.py --- test/benchmark/string_equals.py | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/benchmark/string_equals.py diff --git a/test/benchmark/string_equals.py b/test/benchmark/string_equals.py new file mode 100644 index 00000000..f42947de --- /dev/null +++ b/test/benchmark/string_equals.py @@ -0,0 +1,35 @@ +from __future__ import print_function + +import time +start = time.clock() + +count = 0 +for i in range(0, 1000000): + if "abc" == "abc": + count = count + 1 + if "a slightly longer string" == \ + "a slightly longer string": + count = count + 1 + if "a significantly longer string but still not overwhelmingly long string" == \ + "a significantly longer string but still not overwhelmingly long string": + count = count + 1 + + if "" == "abc": + count = count + 1 + if "abc" == "abcd": + count = count + 1 + if "changed one character" == "changed %ne character": + count = count + 1 + if "123" == 123: count = count + 1 + if "a slightly longer string" == \ + "a slightly longer string!": + count = count + 1 + if "a slightly longer string" == \ + "a slightly longer strinh": + count = count + 1 + if "a significantly longer string but still not overwhelmingly long string" == \ + "another": + count = count + 1 + +print(count) +print("elapsed: " + str(time.clock() - start))