| 264 | } |
| 265 | |
| 266 | unsigned int |
| 267 | StatisticalTimer::pruneOutliers( sTimerID id , double multiple ) |
| 268 | { |
| 269 | if( clkTicks.empty( ) ) |
| 270 | return 0; |
| 271 | |
| 272 | double mean = getMean( id ); |
| 273 | double stdDev = getStdDev( id ); |
| 274 | |
| 275 | clkVector& clks = clkTicks.at( id ); |
| 276 | |
| 277 | // Look on p. 379, "The C++ Standard Library" |
| 278 | // std::remove_if does not actually erase, it only copies elements, it returns new 'logical' end |
| 279 | clkVector::iterator newEnd = std::remove_if( clks.begin( ), clks.end( ), PruneRange< double,unsigned long long >( mean, multiple*stdDev ) ); |
| 280 | |
| 281 | clkVector::difference_type dist = std::distance( newEnd, clks.end( ) ); |
| 282 | |
| 283 | if( dist != 0 ) |
| 284 | clks.erase( newEnd, clks.end( ) ); |
| 285 | |
| 286 | assert( dist < std::numeric_limits< unsigned int >::max( ) ); |
| 287 | |
| 288 | return static_cast< unsigned int >( dist ); |
| 289 | } |
| 290 | |
| 291 | unsigned int |
| 292 | StatisticalTimer::pruneOutliers( double multiple ) |