db.close() exit() update_time_0 = process_time() for i in range(0, 10000): query.update(choice(keys), *(choice(update_cols))) update_time_1 = process_time() print("Updating 10k records took: \t\t\t", update_time_1 - update_time_0) # Measuring Select Performance select_time_0 = process_time() for i in range(0, 10000): query.select(choice(keys), [1, 1, 1, 1, 1]) select_time_1 = process_time() print("Selecting 10k records took: \t\t\t", select_time_1 - select_time_0) # Measuring Aggregate Performance agg_time_0 = process_time() for i in range(0, 10000, 100): result = query.sum(i, 100, randrange(0, 5)) agg_time_1 = process_time() print("Aggregate 10k of 100 record batch took:\t", agg_time_1 - agg_time_0) # Measuring Delete Performance delete_time_0 = process_time() for i in range(0, 10000): query.delete(906659671 + i) delete_time_1 = process_time() print("Deleting 10k records took: \t\t\t", delete_time_1 - delete_time_0)
records[key][j] = value keys = sorted(list(records.keys())) # for key in keys: # print(records[key]) # print(records[key]) for key in keys: record = query.select(key, 0, [1, 1, 1, 1, 1])[0] error = False for i, column in enumerate(record.columns): if column != records[key][i]: error = True if error: print('select error on', key, ':', record, ', correct:', records[key]) print("Select finished") deleted_keys = sample(keys, 100) for key in deleted_keys: query.delete(key) records.pop(key, None) for i in range(0, 100): r = sorted(sample(range(0, len(keys)), 2)) column_sum = sum(map(lambda x: records[x][0] if x in records else 0, keys[r[0]: r[1] + 1])) result = query.sum(keys[r[0]], keys[r[1]], 0) if column_sum != result: print('sum error on [', keys[r[0]], ',', keys[r[1]], ']: ', result, ', correct: ', column_sum) print("Aggregate finished") # db.close()
updated_columns[i] = value query.update(key, *updated_columns) update_time_1 = process_time() print("Updating 5k records of total 20000 times took: \t\t\t", update_time_1 - update_time_0) # Measuring Aggregate Performance num_batch = 1000 batch_size = 100 keys = sorted(list(records.keys())) agg_time_0 = process_time() for c in range(0, grades_table.num_columns): for i in range(0, num_batch): r0 = sample(range(0, len(keys) - batch_size), 1) r = [r0[0], r0[0] + batch_size] result = query.sum(keys[r[0]], keys[r[1]], c) agg_time_1 = process_time() print("Aggregate 1000 of 100 record batch for each column took:\t", agg_time_1 - agg_time_0) # Measuring Delete Performance delete_time_0 = process_time() keys = sorted(list(records.keys())) for mykey in keys: query.delete(mykey) delete_time_1 = process_time() print("Deleting 5k records took: \t\t\t", delete_time_1 - delete_time_0) db.close() os.system("rm -rf ECS165")