diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index 4f9e332..d7d8b6e 100644 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -81,12 +81,87 @@ class HyriseConnection(object): return self.__aggregatePerfArray(perf) + +queries = { + 'select-1': { + 'sql': "SELECT name, city FROM students WHERE grade <= 2.0", + 'json': """{"operators":{"0":{"type":"GetTable","name":"students"},"1":{"type":"SimpleTableScan","predicates":[{"type":"LTE_V","in":0,"f":"grade","value":2,"vtype":1}]},"2":{"type":"ProjectionScan","fields":["name","city"]}},"edges":[["0","1"],["1","2"]]}""", + + 'prepare': "PREPARE sel_test: SELECT name, city FROM students WHERE grade <= ?", + 'execute': "EXECUTE sel_test(2.0);" + + }, + + 'insert-1': { + 'sql': "INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3);", + 'json': """{"operators":{"0":{"type":"GetTable","name":"students"},"1":{"type":"InsertScan","data":[["Max",42,"Musterhausen",2.3]]},"commit":{"type":"Commit"}},"edges":[["0","1"],["1","commit"]]}""" + }, + + 'insert-2': { + 'sql': """ + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + """, + 'json': """{ + "operators": { + "0": { + "type": "GetTable", + "name": "students" + }, + "1": { + "type": "InsertScan", + "data": [ + ["Max", 42, "Musterhausen", 2.3], + ["Max", 42, "Musterhausen", 2.3], + ["Max", 42, "Musterhausen", 2.3], + ["Max", 42, "Musterhausen", 2.3], + ["Max", 42, "Musterhausen", 2.3], + ["Max", 42, "Musterhausen", 2.3], + ["Max", 42, "Musterhausen", 2.3], + ["Max", 42, "Musterhausen", 2.3] + ] + }, + "commit" : { + "type" : "Commit" + } + }, + "edges": [["0","1"],["1","commit"]] + }""", + 'prepare': """PREPARE batch_insert { + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + INSERT INTO students VALUES ('Max', 42, 'Musterhausen', 2.3); + }""", + 'execute': "EXECUTE batch_insert;" + } +} + if __name__ == '__main__': hyrise = HyriseConnection('localhost', 5000) # Load Table hyrise.executeSQL("CREATE TABLE IF NOT EXISTS students FROM TBL FILE 'test/students.tbl';") - print hyrise.executeSQL("SELECT name, city FROM students WHERE grade <= 2.0", 50) + query = queries['insert-2'] - print hyrise.executeJSON("""{"operators":{"0":{"type":"GetTable","name":"students"},"1":{"type":"SimpleTableScan","predicates":[{"type":"LTE_V","in":0,"f":"grade","value":2,"vtype":1}]},"2":{"type":"ProjectionScan","fields":["name","city"]}},"edges":[["0","1"],["1","2"]]}""", 50) + times = 50 + + + # if 'prepare' in query: hyrise.executeSQL(query['prepare']) + + if 'sql' in query: print 'SQL: ', hyrise.executeSQL(query['sql'], times) + + if 'execute' in query: print 'Prepared: ', hyrise.executeSQL(query['execute'], times) + + # if 'json' in query: print 'JSON: ', hyrise.executeJSON(query['json'], times) diff --git a/run_analysis.sh b/run_analysis.sh deleted file mode 100755 index 35132a3..0000000 --- a/run_analysis.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -make clean -C src/ -make analysis -C src/ - -echo "\n\n" - -./bin/analysis "SELECT * FROM t1 UNION SELECT abc AS t FROM t2 ORDER BY col3 LIMIT 10;" -./bin/analysis "INSERT INTO students (name, city, age) VALUES ('Max', 'Musterhausen', 5);" -./bin/analysis "INSERT INTO students (name, city) SELECT * FROM employees;" - -echo "\n\n" \ No newline at end of file