forked from Unstructured-IO/unstructured
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime_partition.py
More file actions
38 lines (27 loc) · 1017 Bytes
/
time_partition.py
File metadata and controls
38 lines (27 loc) · 1017 Bytes
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
import os
import sys
import time
from unstructured.partition.auto import partition
def warm_up_process(filename):
warmup_dir = os.path.join(os.path.dirname(__file__), "warmup-docs")
warmup_file = os.path.join(warmup_dir, f"warmup{os.path.splitext(filename)[1]}")
if os.path.exists(warmup_file):
partition(warmup_file, strategy="fast")
else:
partition(filename, strategy="fast")
def measure_execution_time(filename, iterations, strategy):
total_time = 0.0
for _ in range(iterations):
start_time = time.time()
partition(filename, strategy=strategy)
end_time = time.time()
execution_time = end_time - start_time
total_time += execution_time
average_time = total_time / iterations
print("Average time:", average_time)
if __name__ == "__main__":
filename = sys.argv[1]
iterations = int(sys.argv[2])
strategy = sys.argv[3]
warm_up_process(filename)
measure_execution_time(filename, iterations, strategy)