@@ -64,7 +64,7 @@ function weighted_reservoir_sample_parallel_1_pass(rngs, a, ws, n)
64
64
nt = Threads. nthreads ()
65
65
ss = Vector {Vector{eltype(a)}} (undef, nt)
66
66
w_sums = Vector {Float64} (undef, nt)
67
- chunks_inds = chunks (a; n= nt)
67
+ chunks_inds = index_chunks (a; n= nt)
68
68
Threads. @threads for (i, inds) in enumerate (chunks_inds)
69
69
s = weighted_reservoir_sample_seq (rngs[i], @view (a[inds]), @view (ws[inds]), n)
70
70
ss[i], w_sums[i] = s
84
84
85
85
function weighted_reservoir_sample_parallel_2_pass (rngs, a, ws, n)
86
86
nt = Threads. nthreads ()
87
- chunks_inds = chunks (a; n= nt)
87
+ chunks_inds = index_chunks (a; n= nt)
88
88
w_sums = Vector {Float64} (undef, nt)
89
89
Threads. @threads for (i, inds) in enumerate (chunks_inds)
90
90
w_sums[i] = sum (@view (ws[inds]))
102
102
103
103
function sample_parallel_2_pass (rngs, a, ws, n)
104
104
nt = Threads. nthreads ()
105
- chunks_inds = chunks (a; n= nt)
105
+ chunks_inds = index_chunks (a; n= nt)
106
106
w_sums = Vector {Float64} (undef, nt)
107
107
Threads. @threads for (i, inds) in enumerate (chunks_inds)
108
108
w_sums[i] = sum (@view (ws[inds]))
@@ -190,26 +190,28 @@ def sample_times_numpy():
190
190
"""
191
191
times_numpy = py " sample_times_numpy()"
192
192
193
- f = Figure (backgroundcolor = RGBf (0.98 , 0.98 , 0.98 ), size = (1100 , 700 ) );
193
+ f = Figure (backgroundcolor = RGBf (0.98 , 0.98 , 0.98 ), size = (700 , 600 ), dpi = 1200 );
194
194
195
195
ax1 = Axis (f[1 , 1 ], yscale= log10, xscale= log10,
196
196
yminorticksvisible = true , yminorgridvisible = true ,
197
- yminorticks = IntervalsBetween (10 ))
197
+ yminorticks = IntervalsBetween (10 ), xticklabelsize= 15 , yticklabelsize= 15 , titlesize= 16 ,
198
+ xlabelsize= 17 , ylabelsize= 17 ,)
198
199
199
- scatterlines! (ax1, [10 ^ i/ 10 ^ 8 for i in 2 : 7 ], times_numpy[3 : end ], label = " numpy.choice sequential" , marker = :circle , markersize = 12 , linestyle = :dot )
200
- scatterlines! (ax1, [10 ^ i/ 10 ^ 8 for i in 2 : 7 ], times_other[3 : end ], label = " StatsBase.sample sequential" , marker = :rect , markersize = 12 , linestyle = :dot )
201
- scatterlines! (ax1, [10 ^ i/ 10 ^ 8 for i in 2 : 7 ], times_other_parallel[3 : end ], label = " StatsBase.sample parallel (2 passes)" , marker = :diamond , markersize = 12 , linestyle = :dot )
202
- scatterlines! (ax1, [10 ^ i/ 10 ^ 8 for i in 2 : 7 ], times_single_thread[3 : end ], label = " WRSWR-SKIP sequential" , marker = :hexagon , markersize = 12 , linestyle = :dot )
203
- scatterlines! (ax1, [10 ^ i/ 10 ^ 8 for i in 2 : 7 ], times_multi_thread[3 : end ], label = " WRSWR-SKIP parallel (1 pass)" , marker = :cross , markersize = 12 , linestyle = :dot )
204
- scatterlines! (ax1, [10 ^ i/ 10 ^ 8 for i in 2 : 7 ], times_multi_thread_2[3 : end ], label = " WRSWR-SKIP parallel (2 passes)" , marker = :xcross , markersize = 12 , linestyle = :dot )
205
- Legend (f[2 ,1 ], ax1, labelsize= 10 , framevisible = false , orientation = :horizontal )
200
+ scatterlines! (ax1, [10 ^ i/ 10 ^ 8 for i in 2 : 7 ], times_numpy[3 : end ]. / 10 ^ 3 , label = " numpy.choice sequential" , marker = :circle , markersize = 12 , linestyle = :dot )
201
+ scatterlines! (ax1, [10 ^ i/ 10 ^ 8 for i in 2 : 7 ], times_other[3 : end ]. / 10 ^ 3 , label = " StatsBase.sample sequential" , marker = :rect , markersize = 12 , linestyle = :dot )
202
+ scatterlines! (ax1, [10 ^ i/ 10 ^ 8 for i in 2 : 7 ], times_other_parallel[3 : end ]. / 10 ^ 3 , label = " StatsBase.sample parallel (2 passes)" , marker = :diamond , markersize = 12 , linestyle = :dot )
203
+ scatterlines! (ax1, [10 ^ i/ 10 ^ 8 for i in 2 : 7 ], times_single_thread[3 : end ]. / 10 ^ 3 , label = " WRSWR-SKIP sequential" , marker = :hexagon , markersize = 12 , linestyle = :dot )
204
+ scatterlines! (ax1, [10 ^ i/ 10 ^ 8 for i in 2 : 7 ], times_multi_thread[3 : end ]. / 10 ^ 3 , label = " WRSWR-SKIP parallel (1 pass)" , marker = :cross , markersize = 12 , linestyle = :dot )
205
+ scatterlines! (ax1, [10 ^ i/ 10 ^ 8 for i in 2 : 7 ], times_multi_thread_2[3 : end ]. / 10 ^ 3 , label = " WRSWR-SKIP parallel (2 passes)" , marker = :xcross , markersize = 12 , linestyle = :dot )
206
+ Legend (f[2 ,1 ], ax1, labelsize= 12 , framevisible = false , orientation = :horizontal , nbanks = 3 )
206
207
207
208
ax1. xtickformat = x -> string .(round .(x.* 100 , digits= 10 )) .* " %"
208
209
ax1. title = " Comparison between weighted sampling algorithms in a non-streaming context"
209
210
ax1. xticks = [10 ^ (i)/ 10 ^ 8 for i in 2 : 7 ]
211
+ ax1. yticks = [10 ^ float (i) for i in - 1 : 1 ]
210
212
211
213
ax1. xlabel = " sample ratio"
212
- ax1. ylabel = " time (ms )"
214
+ ax1. ylabel = " time (s )"
213
215
214
216
f
215
217
save (" comparison_WRSWR_SKIP_alg_no_stream.png" , f)
0 commit comments