Skip to content

Commit 64b984e

Browse files
Merge pull request #820 from benjchristensen/fix-CompositeSubscriptionAddRemovePerf
Git keeps modifying this file so committing it how it wants it.
2 parents 3c537f8 + fe48c72 commit 64b984e

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed
Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
package rx.subscriptions;
2-
3-
import rx.perf.AbstractPerformanceTester;
4-
import rx.util.functions.Action0;
5-
6-
public class CompositeSubscriptionAddRemovePerf extends AbstractPerformanceTester {
7-
public static void main(String[] args) {
8-
final CompositeSubscriptionAddRemovePerf spt = new CompositeSubscriptionAddRemovePerf();
9-
try {
10-
spt.runTest(new Action0() {
11-
@Override
12-
public void call() {
13-
spt.timeAddAndRemove();
14-
}
15-
});
16-
} catch (Exception e) {
17-
e.printStackTrace();
18-
}
19-
}
20-
21-
/**
22-
* Test simple add + remove on a composite.
23-
*
24-
* With old Composite add/remove:
25-
*
26-
* Run: 10 - 14,985,141 ops/sec
27-
* Run: 11 - 15,257,104 ops/sec
28-
* Run: 12 - 14,797,996 ops/sec
29-
* Run: 13 - 14,438,643 ops/sec
30-
* Run: 14 - 14,985,864 ops/sec
31-
*
32-
* With optimized Composite add/remove:
33-
*
34-
* Run: 10 - 19,802,782 ops/sec
35-
* Run: 11 - 18,896,021 ops/sec
36-
* Run: 12 - 18,829,296 ops/sec
37-
* Run: 13 - 19,729,876 ops/sec
38-
* Run: 14 - 19,830,678 ops/sec
39-
*
40-
* about 32% increase
41-
*/
42-
void timeAddAndRemove() {
43-
CompositeSubscription csub = new CompositeSubscription();
44-
BooleanSubscription bs = new BooleanSubscription();
45-
for (int i = 0; i < REPETITIONS; i++) {
46-
csub.add(bs);
47-
csub.remove(bs);
48-
}
49-
}
50-
}
1+
package rx.subscriptions;
2+
3+
import rx.perf.AbstractPerformanceTester;
4+
import rx.util.functions.Action0;
5+
6+
public class CompositeSubscriptionAddRemovePerf extends AbstractPerformanceTester {
7+
public static void main(String[] args) {
8+
final CompositeSubscriptionAddRemovePerf spt = new CompositeSubscriptionAddRemovePerf();
9+
try {
10+
spt.runTest(new Action0() {
11+
@Override
12+
public void call() {
13+
spt.timeAddAndRemove();
14+
}
15+
});
16+
} catch (Exception e) {
17+
e.printStackTrace();
18+
}
19+
}
20+
21+
/**
22+
* Test simple add + remove on a composite.
23+
*
24+
* With old Composite add/remove:
25+
*
26+
* Run: 10 - 14,985,141 ops/sec
27+
* Run: 11 - 15,257,104 ops/sec
28+
* Run: 12 - 14,797,996 ops/sec
29+
* Run: 13 - 14,438,643 ops/sec
30+
* Run: 14 - 14,985,864 ops/sec
31+
*
32+
* With optimized Composite add/remove:
33+
*
34+
* Run: 10 - 19,802,782 ops/sec
35+
* Run: 11 - 18,896,021 ops/sec
36+
* Run: 12 - 18,829,296 ops/sec
37+
* Run: 13 - 19,729,876 ops/sec
38+
* Run: 14 - 19,830,678 ops/sec
39+
*
40+
* about 32% increase
41+
*/
42+
void timeAddAndRemove() {
43+
CompositeSubscription csub = new CompositeSubscription();
44+
BooleanSubscription bs = new BooleanSubscription();
45+
for (int i = 0; i < REPETITIONS; i++) {
46+
csub.add(bs);
47+
csub.remove(bs);
48+
}
49+
}
50+
}

0 commit comments

Comments
 (0)