-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (31 loc) · 1.03 KB
/
main.py
File metadata and controls
39 lines (31 loc) · 1.03 KB
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
from tracemalloc import start
from xml_parser import Parser
import sys
from indexer import Indexer
from page import Page
import os
from time import time
import subprocess
if __name__ == "__main__":
# import cProfile
# import pstats
# with cProfile.Profile() as profile:
if not os.path.exists(sys.argv[2]):
os.makedirs(sys.argv[2])
start_time = time()
parser = Parser(sys.argv[1])
ind = Indexer()
ind.writePages()
ind.writeTitleFile()
finalToken = ind.mergedata()
end_time = time()
initialToken = len(Page.uniqueWords)
print(f"Time taken: {end_time - start_time}")
# size = os.path.getsize(sys.argv[2])
size = subprocess.check_output(['du','-sh', sys.argv[2]]).split()[0].decode('utf-8')
stat_file = open(sys.argv[3], "w")
stat_file.write(f"{size}\n{str(finalToken)}\n{Indexer.final_file_count}")
stat_file.close()
# stats = pstats.Stats(profile)
# stats.sort_stats(pstats.SortKey.TIME)
# stats.dump_stats(filename="profile.prof")