Changeset: f8e0946dc0c0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f8e0946dc0c0
Modified Files:
        monetdb5/extras/pyapi/Benchmarks/monetdb_testing.py
        monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh
Branch: pyapi
Log Message:

Faster string generation for testing.


diffs (104 lines):

diff --git a/monetdb5/extras/pyapi/Benchmarks/monetdb_testing.py 
b/monetdb5/extras/pyapi/Benchmarks/monetdb_testing.py
--- a/monetdb5/extras/pyapi/Benchmarks/monetdb_testing.py
+++ b/monetdb5/extras/pyapi/Benchmarks/monetdb_testing.py
@@ -285,36 +285,48 @@ elif str(arguments[1]).lower() == "strin
                 import string
                 result = ""
                 for i in range(0, length):
-                    result += random.choice(string.printable)
+                    result += random.choice(['0', '1', '2', '3', '4', '5', 
'6', '7', '8', '9'])
                 return result
             import random
             import math
             byte_size = mb * 1000 * 1000
             string_size_byte = length
             string_count = int(byte_size / string_size_byte)
-            strings = numpy.zeros(string_count, dtype='S' + str(length))
-            for i in range(0, string_count):
-                strings[i] = random_string(length)
-            return strings
+            if length < 15:
+                min_int = math.pow(10, length - 1)
+                max_int = math.pow(10, length) - 1
+                strings = numpy.random.random_integers(min_int, max_int, 
string_count).astype('S' + str(length))
+                return strings
+            else:
+                strings = numpy.zeros(string_count, dtype='S' + str(length))
+                for i in range(0, string_count):
+                    strings[i] = random_string(length)
+                return strings
         cursor.execute(export_function(generate_strings_samelength, ['float', 
'integer'], ['i string'], table=True, test=False))
     else:
         def generate_strings_samelength(mb, length):
             def random_string(length):
                 import random
                 import string
-                result = unicode('')
+                result = ""
                 for i in range(0, length):
-                    result += random.choice(string.printable)
+                    result += random.choice(['0', '1', '2', '3', '4', '5', 
'6', '7', '8', '9'])
                 return result
             import random
             import math
             byte_size = mb * 1000 * 1000
             string_size_byte = length
             string_count = int(byte_size / string_size_byte)
-            strings = numpy.zeros(string_count, dtype='U' + str(length))
-            for i in range(0, string_count - 1):
-                strings[i] = random_string(length)
-            strings[string_count - 1] = random_string(length - 1) + 
unichr(0x100)
+            strings = None
+            if length < 15:
+                min_int = math.pow(10, length - 1)
+                max_int = math.pow(10, length) - 1
+                strings = numpy.random.random_integers(min_int, max_int, 
string_count).astype('U' + str(length))
+            else:
+                strings = numpy.zeros(string_count, dtype='U' + str(length))
+                for i in range(0, string_count):
+                    strings[i] = random_string(length)
+            strings[string_count - 1] = unichr(0x100) * length
             return strings
         cursor.execute(export_function(generate_strings_samelength, ['float', 
'integer'], ['i string'], table=True, test=False))
 
@@ -449,7 +461,13 @@ elif "factorial" in str(arguments[1]).lo
         mb.append(float(arguments[i]))
 
     for size in mb:
-        cursor.execute('create table integers as SELECT * FROM 
generate_integers(' + str(size) + ') with data;')
+        cursor.execute('CREATE TABLE integers (i integer);')
+        temp_size = size
+        for increment in range(0, int(math.ceil(float(size) / 
float(max_size)))):
+            current_size = temp_size if temp_size < max_size else max_size
+            cursor.execute('INSERT INTO integers SELECT * FROM 
generate_integers(' + str(current_size) + ');')
+            temp_size -= max_size
+
         results = [[], [], []]
         for i in range(0,test_count):
             result_file = open(temp_file, 'w+')
@@ -510,7 +528,12 @@ elif str(arguments[1]).lower() == "pquan
         mb.append(float(arguments[i]))
 
     for size in mb:
-        cursor.execute('create table integers as SELECT * FROM 
generate_integers(' + str(size) + ') with data;')
+        cursor.execute('CREATE TABLE integers (i integer);')
+        temp_size = size
+        for increment in range(0, int(math.ceil(float(size) / 
float(max_size)))):
+            current_size = temp_size if temp_size < max_size else max_size
+            cursor.execute('INSERT INTO integers SELECT * FROM 
generate_integers(' + str(current_size) + ');')
+            temp_size -= max_size
 
         results = []
         for i in range(0,test_count):
diff --git a/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh 
b/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh
--- a/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh
+++ b/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh
@@ -35,7 +35,7 @@ export STRINGUNICODE_TESTING_NTESTS=10
 
 # Multithreading tests
 export MULTITHREADING_NR_THREADS="1 2 3 4 5 6 7 8"
-export MULTITHREADING_TESTING_SIZES="10"
+export MULTITHREADING_TESTING_SIZES="1"
 #amount of tests for each thread
 export MULTITHREADING_TESTING_NTESTS=10
 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to