#endif /** * Initializes the timer with the current time * * @param timer A pointer to UTimer struct to receive the current time
*/ staticinlinevoid U_EXPORT2
utimer_getTime(UTimer* timer){
uprv_initFrequency(timer);
uprv_start(timer);
}
/** * Returns the difference in times between timer1 and timer2 by subtracting * timer1's time from timer2's time * * @param timer1 A pointer to UTimer struct to be used as starting time * @param timer2 A pointer to UTimer struct to be used as end time * @return Time in seconds
*/ staticinlinedouble U_EXPORT2
utimer_getDeltaSeconds(UTimer* timer1, UTimer* timer2){ if(uprv_compareFrequency(timer1,timer2)){ return uprv_delta(timer1,timer2);
} /* got error return -1 */ return -1;
}
/** * Returns the time elapsed from the starting time represented by the * UTimer struct pointer passed * @param timer A pointer to UTimer struct to be used as starting time * @return Time elapsed in seconds
*/ staticinlinedouble U_EXPORT2
utimer_getElapsedSeconds(UTimer* timer){
UTimer temp;
utimer_getTime(&temp); return uprv_delta(timer,&temp);
}
/** * Executes the function pointed to for a given time and returns exact time * taken and number of iterations of the loop * @param thresholTimeVal * @param loopCount output param to receive the number of iterations * @param fn The function to be executed * @param param Parameters to be passed to the fn * @return the time elapsed in seconds
*/ staticinlinedouble U_EXPORT2
utimer_loopUntilDone(double thresholdTimeVal,
int32_t* loopCount,
FunctionToBeTimed fn, void* param){
UTimer timer; double currentVal=0;
*loopCount = 0;
utimer_getTime(&timer); for(;currentVal<thresholdTimeVal;){
fn(param);
currentVal = utimer_getElapsedSeconds(&timer);
(*loopCount)++;
} return currentVal;
}
#endif
Messung V0.5
¤ Dauer der Verarbeitung: 0.24 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.