-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptimize_speed.py
68 lines (50 loc) · 1.7 KB
/
optimize_speed.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from channel import ClosableChannel
from posacts import HashStoreChannelListener, LatestActualityListener
from hashstore import NoutHashStore
from memoization import Stores, Memoization
from filehandler import read_from_file
from dsn.s_expr.h_utils import view_past_from_present
from dsn.historiography.legato import (
HistoriographyNoteNoutHash,
HistoriographyNoteNout,
HistoriographyNoteSlur,
HistoriographyNoteCapo,
)
from dsn.historiography.clef import SetNoteNoutHash
from time import clock
class Timer:
def __init__(self, name):
self.name = name
def __enter__(self):
self.start = clock()
return self
def __exit__(self, *args):
self.end = clock()
print(self.name, self.end - self.start)
filename = 'bigfile'
historiography_note_nout_store = NoutHashStore(
HistoriographyNoteNoutHash, HistoriographyNoteNout, HistoriographyNoteCapo)
# This is the main channel of PosActs for our application.
history_channel = ClosableChannel()
possible_timelines = HashStoreChannelListener(history_channel).possible_timelines
lnh = LatestActualityListener(history_channel)
read_from_file(filename, history_channel)
nout_hash = lnh.nout_hash
stores = Stores(
possible_timelines,
historiography_note_nout_store,
)
m = Memoization()
for i in range(2):
# this is what the HistoryWidget would do
historiography_note_nout = HistoriographyNoteSlur(
SetNoteNoutHash(nout_hash),
HistoriographyNoteNoutHash.for_object(HistoriographyNoteCapo()),
)
with Timer('2'):
liveness_annotated_hashes = view_past_from_present(
m,
stores,
historiography_note_nout,
nout_hash,
)