monoclock

package module
v0.0.0-...-1c0490e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2013 License: MIT Imports: 2 Imported by: 1

README

A monotonic clock and timer for Go. Currently available only on Linux, but I would like to expand it to support at least Windows and OS X in the near future.

Check out the GoDoc at https://godoc.org/github.com/pavben/monoclock

Example

package main

import (
	"fmt"
	"github.com/pavben/monoclock"
)

func main() {
	timer := monoclock.NewMonoTimer()

	// do something here that takes some time
	for i := 0; i < 5000; i++ {
		fmt.Printf("wheeeeee\n")
	}

	fmt.Printf("Spamming your console took %dms\n", timer.Value())
}

Documentation

Index

Constants

View Source
const CLOCK_MONOTONIC_RAW = 4

Variables

This section is empty.

Functions

func GetMonoTime

func GetMonoTime() int64

Returns the time of the system monotonic clock in milliseconds.

Types

type MonoTimer

type MonoTimer struct {
	// contains filtered or unexported fields
}

func NewMonoTimer

func NewMonoTimer() *MonoTimer

Creates a new monotonic timer and starts it.

func (*MonoTimer) Value

func (self *MonoTimer) Value() int64

Returns the number of milliseconds that have elapsed since this MonoTimer was created.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL