Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

単調増加する内部タイマーをつかうmonotonicメソッド

とあるロボットのプログラムを読んでいた時にmonotonicメソッドなるものを見つける

time.monotonic()
#>> 3585.757559266

Python公式によると

Return the value (in fractional seconds) of a monotonic clock, i.e. a clock that cannot go backwards.
The clock is not affected by system clock updates.
The reference point of the returned value is undefined, so that only the difference between the results of two calls is valid.

とあり、巻き戻ったりせず単調増加する……らしい。
ただしNTPやadjtimeの様に内部タイマーに直接介入するようなのは流石にダメな模様。