src/Analytics.php
private function combineSumPoints($points1, $points2) {
        $pointsCount = count($points1);
        $currPoint = 0;
        foreach ($points2 as $point2) {
            $pointFound = false;
            //leverage the fact that points are sorted and improve O(n^2)
            while ($currPoint < $pointsCount) {
                $point1 = $points1[$currPoint];
                if ($point1['time'] == $point2['time']) {
                    $points1[$currPoint]['sum'] += $point2['sum'];
                    $currPoint++;
                    $pointFound = true;
                    break;
                }
                $currPoint++;
            }
            //point not found in downsampled array, then just append
            if (!$pointFound) {
                $points1[] = $point2;
            }
        }

        return $points1;
    }
private function combineSumPoints($points1, $points2) {
        $pointsCount = count($points1);
        $currPoint = 0;
        foreach ($points2 as $point2) {
            $pointFound = false;
            //leverage the fact that points are sorted and improve O(n^2)
            while ($currPoint < $pointsCount) {
                $point1 = $points1[$currPoint];
                if ($point1['time'] == $point2['time']) {
                    $points1[$currPoint]['sum'] += $point2['sum'];
                    $currPoint++;
                    $pointFound = true;
                    break;
                }
                $currPoint++;
            }
            //point not found in downsampled array, then just append
            if (!$pointFound) {
                $points1[] = $point2;
            }
        }

        return $points1;
    }
private function combineSumPoints ( $ points1 , $ points2 ) { $ pointsCount = count ( $ points1 ) ; $ currPoint = 0 ; foreach ( $ points2 as $ point2 ) { $ pointFound = false ; //leverage the fact that points are sorted and improve O(n^2) while ( $ currPoint < $ pointsCount ) { $ point1 = $ points1 [ $ currPoint ] ; if ( $ point1 [ 'time' ] == $ point2 [ 'time' ] ) { $ points1 [ $ currPoint ] [ 'sum' ] += $ point2 [ 'sum' ] ; $ currPoint ++ ; $ pointFound = true ; break ; } $ currPoint ++ ; } //point not found in downsampled array, then just append if ( ! $ pointFound ) { $ points1 [ ] = $ point2 ; } } return $ points1 ; }
Combine downsampled and non-downsampled points

@param array $points1
@param array $points2
@return array
Combine downsampled and non - downsampled points