forked from automerge/automerge-py
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbench.py
48 lines (35 loc) · 1.03 KB
/
bench.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
#!/usr/bin/env python3
import json
from pathlib import Path
import time
import automerge
edits = json.loads(Path("edits.json").read_text())
commands = []
for i in range(len(edits)):
pos = edits[i][0]
d = edits[i][1]
vals = ""
for j in range(2, len(edits[i])):
vals += edits[i][j]
commands.append((pos, d, vals));
for _ in range(100):
print(_)
doc = automerge.init()
now = time.perf_counter()
with automerge.transaction(doc) as d:
d.text = automerge.Text("")
t = d.text
for (pos, dd, vals) in commands:
t[pos:pos+dd] = vals
print(f"Done in {time.perf_counter() - now} s", );
# print(doc.text)
# let save = Instant::now();
# let bytes = doc.save();
# println!("Saved in {} ms", save.elapsed().as_millis());
# let load = Instant::now();
# let _ = Automerge::load(&bytes).unwrap();
# println!("Loaded in {} ms", load.elapsed().as_millis());
# let get_txt = Instant::now();
# doc.text(&text)?;
# println!("Text in {} ms", get_txt.elapsed().as_millis());
# Ok(())