profile

inline fun profile(name: String = "Profiler", repeats: Int = 10, printResults: Boolean = true, operation: () -> Unit): PerformanceCounter

Profiles the given operation using a PerformanceCounter. The operation will be repeated repeats times to gather the performance data. PerformanceCounter.tick will be called after each operation. repeats will be used to set the window size of the PerformanceCounter. If printResults is set to true, a short summary will be printed by the application.

PerformanceCounter used for the profiling will be returned, so that the profiling data can be analyzed and further tests can be performed. Note that to perform further profiling with this PerformanceCounter of a different operation, PerformanceCounter.reset should be called.


inline fun PerformanceCounter.profile(repeats: Int = if (time.mean != null) time.mean.windowSize else 10, printResults: Boolean = true, operation: () -> Unit)

Profiles the given operation using this PerformanceCounter. The operation will be repeated repeats times to gather the performance data. PerformanceCounter.tick will be called after each operation. By default, repeats is set to the window size passed to the PerformanceCounter constructor or 10 if the window size is set to 1. If printResults is set to true, a short summary will be printed by the application.

Note that to perform further profiling with this PerformanceCounter of a different operation, PerformanceCounter.reset should be called.