package ru.dbotthepony.kstarbound.util

import kotlinx.coroutines.delay

class ExecutionTimePacer(private val budget: Long, private val pause: Long) {
	private var origin = System.nanoTime()

	suspend fun measureAndSuspend() {
		if (System.nanoTime() - origin >= budget) {
			delay(pause)
			origin = System.nanoTime()
		}
	}
}
