Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
davitmamrikishvili committed Aug 8, 2024
1 parent 27e5404 commit 9ead2c8
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,21 @@ def get_iteration_speed_plus():
for i in range(1, 122):
data = data + Data.from_json(f"benchmark/json{i}.gz", gzip=True)

start_time = time.time()
_iterate_and_print_stats(start_time, data)
_iterate_and_print_stats(data)


def get_iteration_speed_plus_equals():
data = Data.from_json(f"benchmark/json0.gz", gzip=True)
for i in range(1, 122):
data += Data.from_json(f"benchmark/json{i}.gz", gzip=True)

start_time = time.time()
_iterate_and_print_stats(start_time, data)
_iterate_and_print_stats(data)


def get_iteration_speed_list_comprehension():
data = Data([Data.from_json(f"benchmark/json{i}.gz", gzip=True) for i in range(122)])

start_time = time.time()
_iterate_and_print_stats(start_time, data)
_iterate_and_print_stats(data)


def _generate_data():
Expand All @@ -40,7 +37,8 @@ def _generate_data():
data.to_json_lines(f"benchmark/json{i}.gz", gzip=True, overwrite=True)


def _iterate_and_print_stats(start_time, data):
def _iterate_and_print_stats(data):
start_time = time.time()
j = 0
for _ in data:
j += 1
Expand Down

0 comments on commit 9ead2c8

Please sign in to comment.