5
5
6
6
np .random .seed (1 )
7
7
8
+
8
9
def test_performance_scatter3d ():
9
10
N = 10000
10
11
11
12
x = np .random .randn (N )
12
- y = np .random .randn (N ).astype (' float32' )
13
- z = np .random .randint (size = N , low = 0 , high = 256 , dtype = ' uint8' )
14
- c = np .random .randint (size = N , low = - 10 , high = 10 , dtype = ' int8' )
13
+ y = np .random .randn (N ).astype (" float32" )
14
+ z = np .random .randint (size = N , low = 0 , high = 256 , dtype = " uint8" )
15
+ c = np .random .randint (size = N , low = - 10 , high = 10 , dtype = " int8" )
15
16
16
17
# Test the performance with lists
17
18
list_start = time .time ()
18
- fig = go .Figure (data = [go .Scatter3d (
19
- x = x .tolist (),
20
- y = y .tolist (),
21
- z = z .tolist (),
22
- marker = dict (color = c .tolist ()),
23
- mode = 'markers' ,
24
- opacity = 0.2
25
- )])
19
+ fig = go .Figure (
20
+ data = [
21
+ go .Scatter3d (
22
+ x = x .tolist (),
23
+ y = y .tolist (),
24
+ z = z .tolist (),
25
+ marker = dict (color = c .tolist ()),
26
+ mode = "markers" ,
27
+ opacity = 0.2 ,
28
+ )
29
+ ]
30
+ )
26
31
list_time_elapsed = time .time () - list_start
27
32
28
33
# Test the performance with base64 arrays
@@ -32,14 +37,15 @@ def test_performance_scatter3d():
32
37
y = b64 (y ),
33
38
z = b64 (z ),
34
39
marker = dict (color = b64 (c )),
35
- mode = ' markers' ,
36
- opacity = 0.2
40
+ mode = " markers" ,
41
+ opacity = 0.2 ,
37
42
)
38
43
b64_time_elapsed = time .time () - b64_start
39
44
40
45
# b64 should be faster than raw
41
46
assert (b64_time_elapsed / list_time_elapsed ) < 0.75
42
47
48
+
43
49
def test_performance_b64_float64 ():
44
50
np_arr_1 = np .random .random (10000 )
45
51
np_arr_2 = np .random .random (10000 )
0 commit comments