@@ -64,7 +64,7 @@ function weighted_reservoir_sample_parallel_1_pass(rngs, a, ws, n)
6464 nt = Threads. nthreads ()
6565 ss = Vector {Vector{eltype(a)}} (undef, nt)
6666 w_sums = Vector {Float64} (undef, nt)
67- chunks_inds = chunks (a; n= nt)
67+ chunks_inds = index_chunks (a; n= nt)
6868 Threads. @threads for (i, inds) in enumerate (chunks_inds)
6969 s = weighted_reservoir_sample_seq (rngs[i], @view (a[inds]), @view (ws[inds]), n)
7070 ss[i], w_sums[i] = s
8484
8585function weighted_reservoir_sample_parallel_2_pass (rngs, a, ws, n)
8686 nt = Threads. nthreads ()
87- chunks_inds = chunks (a; n= nt)
87+ chunks_inds = index_chunks (a; n= nt)
8888 w_sums = Vector {Float64} (undef, nt)
8989 Threads. @threads for (i, inds) in enumerate (chunks_inds)
9090 w_sums[i] = sum (@view (ws[inds]))
102102
103103function sample_parallel_2_pass (rngs, a, ws, n)
104104 nt = Threads. nthreads ()
105- chunks_inds = chunks (a; n= nt)
105+ chunks_inds = index_chunks (a; n= nt)
106106 w_sums = Vector {Float64} (undef, nt)
107107 Threads. @threads for (i, inds) in enumerate (chunks_inds)
108108 w_sums[i] = sum (@view (ws[inds]))
@@ -190,26 +190,28 @@ def sample_times_numpy():
190190"""
191191times_numpy = py " sample_times_numpy()"
192192
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 );
194194
195195ax1 = Axis (f[1 , 1 ], yscale= log10, xscale= log10,
196196 yminorticksvisible = true , yminorgridvisible = true ,
197- yminorticks = IntervalsBetween (10 ))
197+ yminorticks = IntervalsBetween (10 ), xticklabelsize= 15 , yticklabelsize= 15 , titlesize= 16 ,
198+ xlabelsize= 17 , ylabelsize= 17 ,)
198199
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 )
206207
207208ax1. xtickformat = x -> string .(round .(x.* 100 , digits= 10 )) .* " %"
208209ax1. title = " Comparison between weighted sampling algorithms in a non-streaming context"
209210ax1. xticks = [10 ^ (i)/ 10 ^ 8 for i in 2 : 7 ]
211+ ax1. yticks = [10 ^ float (i) for i in - 1 : 1 ]
210212
211213ax1. xlabel = " sample ratio"
212- ax1. ylabel = " time (ms )"
214+ ax1. ylabel = " time (s )"
213215
214216f
215217save (" comparison_WRSWR_SKIP_alg_no_stream.png" , f)
0 commit comments