OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bench_update Namespace Reference

Classes

class  HeavyAICon
 

Functions

def getOptions
 
def create_and_import_into_table
 
def gen_data
 
def bench_update_query
 
def main
 

Function Documentation

def bench_update.bench_update_query (   heavyai_con,
  table_name,
  tag 
)

Definition at line 41 of file bench_update.py.

Referenced by main().

41 
42 def bench_update_query(heavyai_con, table_name, tag):
43  query = f"UPDATE {table_name} SET a = a + 10, c = c + b, d = d * 2 WHERE MOD(b, 2) = 0"
44  query_times = []
45  for i in range(10):
46  result = heavyai_con.query(query)
47  query_times.append(result._result.execution_time_ms)
48 
49  print(f"Test tag: {tag}\nQuery: {query}\nRaw times(ms): {query_times}\n"
50  f"Avg: {np.average(query_times)}\nMin: {np.min(query_times)}\n"
51  f"Max: {np.max(query_times)}\nMedian: {np.median(query_times)}")
def bench_update_query
Definition: bench_update.py:41

+ Here is the caller graph for this function:

def bench_update.create_and_import_into_table (   heavyai_con,
  table_name,
  file_path 
)

Definition at line 28 of file bench_update.py.

Referenced by main().

28 
29 def create_and_import_into_table(heavyai_con, table_name, file_path):
30  drop_sql = f"DROP TABLE IF EXISTS {table_name}"
31  create_sql = f"CREATE TABLE {table_name} (a INTEGER, b INTEGER, c INTEGER, d DOUBLE)"
32  import_sql = f"COPY {table_name} FROM '{file_path.absolute()}'"
33  heavyai_con.query(drop_sql)
34  heavyai_con.query(create_sql)
35  heavyai_con.query(import_sql)
def create_and_import_into_table
Definition: bench_update.py:28

+ Here is the caller graph for this function:

def bench_update.gen_data (   num_rows)

Definition at line 36 of file bench_update.py.

Referenced by main().

36 
37 def gen_data(num_rows):
38  df = pd.DataFrame(np.random.randint(0, num_rows, size=(num_rows, 4)), columns=['a', 'b', 'c', 'd'])
39  df = df.astype(np.int32)
40  return df

+ Here is the caller graph for this function:

def bench_update.getOptions (   args = None)

Definition at line 9 of file bench_update.py.

Referenced by main().

9 
10 def getOptions(args=None):
11  parser = argparse.ArgumentParser(description='Basic benchmark for update queries')
12  parser.add_argument('-s','--host', help='HEAVY.AI server address', default='localhost')
13  parser.add_argument('-p','--port', help='HEAVY.AI server port', default='6273')
14  parser.add_argument('-d','--db', help='HEAVY.AI database name', default='heavyai')
15  parser.add_argument('-u','--user', help='HEAVY.AI user name', default='admin')
16  parser.add_argument('-w','--password', help='HEAVY.AI password', default='HyperInteractive')
17  parser.add_argument('-r', '--num_rows', help='Number of rows to benchmark with', type=int, default=1_000_000)
18  parser.add_argument('-t', '--tag', help='Tag for test run')
19  return parser.parse_args(args)

+ Here is the caller graph for this function:

def bench_update.main (   argv)

Definition at line 52 of file bench_update.py.

References bench_update_query(), create_and_import_into_table(), gen_data(), and getOptions().

52 
53 def main(argv):
54  options = getOptions(argv)
55  heavyai_con = HeavyAICon(options.user, options.password, options.db, options.host)
56 
57  file_path = Path(f"{options.num_rows}_rand.csv")
58  if not file_path.exists():
59  df = gen_data(options.num_rows)
60  df.to_csv(file_path, index=False)
61 
62  table_name = "update_bench_test"
63  create_and_import_into_table(heavyai_con, table_name, file_path)
64 
65  bench_update_query(heavyai_con, table_name, options.tag)
def create_and_import_into_table
Definition: bench_update.py:28
def bench_update_query
Definition: bench_update.py:41

+ Here is the call graph for this function: