Skip to content

Commit 636156a

Browse files
committed
2x cocotb test speed improvement by being reasonable with the GC
1 parent de6bba2 commit 636156a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/main.py

+11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232

3333
import micropython
3434
import gc
35+
36+
# stash the current value for garbage
37+
# collection threshold (is -1/when full, by default)
38+
GCThreshold = gc.threshold()
39+
40+
# start very aggressive, to keep thing defragged
41+
# as we read in ini and JSON files, etc
3542
gc.threshold(10000)
3643
import ttboard.util.time as time
3744
from ttboard.boot.demoboard_detect import DemoboardDetect
@@ -88,6 +95,7 @@ def stopClocking():
8895
if PowerOnSelfTest.first_boot():
8996
print('First boot!')
9097
PowerOnSelfTest.handle_first_boot()
98+
gc.collect()
9199

92100

93101

@@ -132,6 +140,9 @@ def stopClocking():
132140

133141
print(f"tt.sdk_version={tt.version}")
134142

143+
# end by being so aggressive on collection
144+
gc.threshold(GCThreshold)
145+
135146
# to run tests easily import a module of interest, as below, and then
136147
# run() it
137148

0 commit comments

Comments
 (0)