-
Notifications
You must be signed in to change notification settings - Fork 1
/
external.py
51 lines (45 loc) · 1.52 KB
/
external.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from external_benches import *
import bmark
def benchmark_writes(shape, num_partitions=0, plot=False, **kwargs):
benched = (
fstore.fs_write_pd(shape, num_partitions=num_partitions),
csv.pd_write_csv(shape),
feather.pd_write_feather(shape),
parquet.pd_write_parquet(shape),
pickle.pd_write_pickle(shape),
duckdb.duckdb_write_pd(shape),
)
write_bench = bmark.Benchmark(benched)
header = f'Write benchmark (Table size: {shape[0]:,d}, {shape[1]:,d})'
quiet = plot
result = write_bench.run(header=header, quiet=quiet, **kwargs)
if plot:
result.plot()
return result
def benchmark_reads(shape, num_partitions=0, plot=False, **kwargs):
benched = (
fstore.fs_read_pd(shape, num_partitions=num_partitions),
csv.pd_read_csv(shape),
feather.pd_read_feather(shape),
parquet.pd_read_parquet(shape),
pickle.pd_read_pickle(shape),
duckdb.duckdb_read_pd(shape),
)
read_bench = bmark.Benchmark(benched)
header = f'Read benchmark (Table size: {shape[0]:,d}, {shape[1]:,d})'
quiet = plot
result = read_bench.run(header=header, quiet=quiet, **kwargs)
if plot:
result.plot()
return result
if __name__ == '__main__':
shape = (100_000, 6)
num_partitions = 0
plot = True
run_kwargs = {
'n': 3,
'r': 5,
'sort': True
}
benchmark_writes(shape, num_partitions, plot=plot, **run_kwargs)
benchmark_reads(shape, num_partitions, plot=plot, **run_kwargs)