Skip to content

Commit 8f9879d

Browse files
martinsikdavidwdan
authored andcommitted
added more benchmarks, updated existing from RxJS 5
1 parent 58e654a commit 8f9879d

File tree

6 files changed

+48
-3
lines changed

6 files changed

+48
-3
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
use Rx\Observable;
4+
5+
return function() use ($dummyObserver) {
6+
Observable::range(0, 25)
7+
->bufferWithCount(5)
8+
->subscribe($dummyObserver);
9+
};

benchmark/distinct/distinct.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
use Rx\Observable;
44

5-
return function() use ($dummyObserver) {
6-
Observable::range(1, pow(10, 3))
5+
$source = array_map(function($val) {
6+
return $val % 3;
7+
}, range(0, 25));
8+
9+
return function() use ($source, $dummyObserver) {
10+
Observable::fromArray($source)
711
->distinct()
812
->subscribe($dummyObserver);
913
};

benchmark/filter/filter.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
use Rx\Observable;
44

55
return function() use ($dummyObserver) {
6-
Observable::range(1, pow(10, 3))
6+
Observable::range(0, 50)
77
->filter(function($value) {
88
return $value % 2 == 0;
99
})
10+
->filter(function($value) {
11+
return $value % 10 == 0;
12+
})
1013
->subscribe($dummyObserver);
1114
};

benchmark/skipLast/skipLast.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
use Rx\Observable;
4+
5+
return function() use ($dummyObserver) {
6+
Observable::range(0, 500)
7+
->skipLast(50)
8+
->subscribe($dummyObserver);
9+
};

benchmark/takeLast/takeLast.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
use Rx\Observable;
4+
5+
return function() use ($dummyObserver) {
6+
Observable::range(0, 500)
7+
->takeLast(50)
8+
->subscribe($dummyObserver);
9+
};

benchmark/zip/zip.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
use Rx\Observable;
4+
5+
return function() use ($dummyObserver) {
6+
Observable::range(0, 25)
7+
->zip([Observable::range(0, 25)], function($a, $b) {
8+
return $a + $b;
9+
})
10+
->subscribe($dummyObserver);
11+
};

0 commit comments

Comments
 (0)