// Start timing an operation
PerfLogger.startTiming("LoadMesh")
// Perform the operation
val mesh = loadMeshFromFile(file)
// End timing the operation
PerfLogger.endTiming("LoadMesh")
// Later, you can access the timing information
val timingPair = PerfLogger.timings["LoadMesh"]
val startTime = timingPair?.first
val endTime = timingPair?.second
val elapsedTime = if (startTime != null && endTime != null) endTime - startTime else null
println("Loading mesh took ${elapsedTime}ms")
object PerfLogger
timings
:
HashMap<String, Pair<Long, Long>>
[Get][Set] |
HashMap storing timing information for different operations.
The key is a string identifier for the operation being timed. The value is a Pair where:
Signature
var timings: HashMap<String, Pair<Long, Long>><String, HashMap<String, Pair<Long, Long>><Long, Long>> |
endTiming
(
beingTimed
)
|
Ends timing for an operation and records the elapsed time.
This method records the current system time as the end time for the specified operation. If no timing was started for this operation, this method has no effect.
Signature
fun endTiming(beingTimed: String) Parameters
beingTimed:
String
|
startTiming
(
beingTimed
)
|
Starts timing an operation identified by the given string.
This method records the current system time as the start time for the specified operation. If timing for this operation already exists, it will be overwritten.
Signature
fun startTiming(beingTimed: String) Parameters
beingTimed:
String
|