Skip to content

Commit c524e08

Browse files
committed
Thread example.
1 parent 5af19d8 commit c524e08

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

python-benchmarks/example.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import ctypes
2-
import sys
3-
import inspect
4-
import atexit
5-
import numpy
61
import time
2+
import numpy
73

8-
import gc
94

105
def should_have_no_effect():
116
h(3)

python-benchmarks/threaded.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from time import sleep
2+
import threading
3+
4+
import numpy
5+
6+
def h(i):
7+
return numpy.ones((1024, 1024, 20), dtype=numpy.uint8)
8+
9+
def child1():
10+
return h(30)
11+
12+
def thread1():
13+
data = h(20)
14+
sleep(1)
15+
data2 = child1()
16+
sleep(1)
17+
18+
def child2():
19+
return h(30)
20+
21+
def thread2():
22+
data = h(50)
23+
sleep(1)
24+
data2 = child2()
25+
sleep(1)
26+
27+
threading.Thread(target=thread1).start()
28+
threading.Thread(target=thread2).start()
29+
30+
def main():
31+
data = h(50)
32+
sleep(5)
33+
34+
main()

0 commit comments

Comments
 (0)