Thanks.
I also added a version which scales linearly with # of excluded rows (ecluded rows are removed one by one).
It's quite competitive for small numbers of excluded rows, but performs worse and worse for large numbers.
Around 200 excluded rows it reached the performance of Jim's version and gets then really bad ...
In addition, I found a version ("Jim X"), which is ~ factor 2 faster than Jim's version - and even shorter code:
nonExludedRows = dt << get rows where( Excluded() == 0 );
Most important:
Jarmo's version is by far the best.
</CODE></P><P><SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_4-1667508531636.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="hogi_4-1667508531636.png" style="width: 400px;"><span class="lia-inline-image-display-wrapper" image-alt="hogi_4-1667508531636.png" style="width: 400px;"><img src="https://us.v-cdn.net/6038925/uploads/images/46881iC5718A32059D8FB7/hogi_4-1667508531636.png" role="button" title="hogi_4-1667508531636.png" alt="hogi_4-1667508531636.png" /></span></SPAN></SPAN></P><DIV class="lia-spoiler-container"><A class="lia-spoiler-link" href="#" rel="nofollow noopener noreferrer" target="_blank">View more...</A><NOSCRIPT><DIV class="lia-spoiler-content"><PRE><CODE class=" language-jsl">dt = New Table( "dummy table" );
NR = 10E6;
dt << add rows( NR );
dt << New Column( "random", set each value( Random Uniform( 0, 100 ) ) );
For Each( {percent, idx},
{0.00001, 0.00002, 0.00005, 0.0001, 0.0002, 0.0005, 0.001, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 15, 20, 30, 40, 50, 60,
70, 80, 90, 100},
Print( percent );
dt << Clear Row States;
dt << select where( :random < percent );
dt << Hide and Exclude;
nexcl = N Rows( dt << Get Excluded Rows );
dt << Clear Select;
Wait();
// Jim
bt = HP Time();
allRows = dt << get rows where( Excluded( Row State( Row() ) ) == 0 );
et = HP Time();
time1 = et - bt;
// Jim X
bt = HP Time();
allRows = dt << get rows where( Excluded() == 0 );
et = HP Time();
time2 = et - bt;
// Jarmo
bt = HP Time();
excl_rows = dt << Get Excluded Rows;
et = HP Time();
time3a = et - bt;
all_rows = 1 :: N Rows( dt );
all_rows[excl_rows] = .;
all_rows = Loc(all_rows);
et = HP Time();
time3 = et - bt;
// hogi
If( idx < 11,
bt = HP Time();
excl = dt << Get Excluded Rows;
allRows = (1 :: N Rows( dt ));
For Each( {i, j}, Reverse( excl ), Remove From( allRows, i, 1 ) );
et = HP Time();
time4 = et - bt;
);
Wait();
If( idx == 1,
New Window( "timing results",
tb = Table Box(
Number Col Box( "# excluded", {Nexcl} ),
Number Col Box( "Jim", {time1 / 1000000} ),
Number Col Box( "Jim X", {time2 / 1000000} ),
Number Col Box( "Jarmo", {time3 / 1000000} ),
Number Col Box( "Jarmo (get ... rows)", {time3a / 1000000} ),
Number Col Box( "hogi", {time4 / 1000000} ),
)
)
,
If( idx < 11,
tb << add row( {Nexcl, time1 / 1000000, time2 / 1000000, time3 / 1000000,time3a / 1000000, time4 / 1000000} ),
tb << add row( {Nexcl, time1 / 1000000, time2 / 1000000, time3 / 1000000, time3a / 1000000} )
)
);
);
results = tb << Make Combined Data Table;
gb = results << Graph Builder(
Show Control Panel( 0 ),
Variables( X( :"# excluded"n ), Y( :Jim ), Y( :Jim X, Position( 1 ) ), Y( :Jarmo, Position( 1 ) ), Y( :hogi, Position( 1 ) ) ),
Elements( Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 5 ) ), Smoother( X, Y( 1 ), Y( 2 ), Y( 3 ), Y( 4 ), Legend( 6 ), Lambda( 0.001 ) ) )
);
Report( gb )[AxisBox( 1 )] << {Scale( "Log" ), Min( 1 ), Max( 10000000 )};
Report( gb )[AxisBox( 2 )] << {Scale( "Log" ), Min( 0.1 ), Max( 10 ),Label Row( Show Minor Grid( 1 ) )};
Report( gb )[Text Edit Box( 4 )] << Set Text( "time [s]" )