fastime

package module
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2019 License: MIT Imports: 5 Imported by: 52

README

fastime release CircleCI codecov Codacy Badge Go Report Card GoDoc

Blazing Fast Time Library for golang with zero allocs

Requirement

Go 1.8

Installation

go get github.com/kpango/fastime

Example

    now := fastime.Now()
    defer fastime.Stop()

    // Create Instance
    ft := fastime.New()
    defer ft.Stop()
    ft.Now()

Benchmark

go test -count=5 -run=NONE -bench . -benchmem
goos: darwin
goarch: amd64
pkg: github.com/kpango/fastime
BenchmarkFastime-8   	2000000000	         0.47 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastime-8   	2000000000	         0.48 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastime-8   	2000000000	         0.48 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastime-8   	2000000000	         0.47 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastime-8   	2000000000	         0.47 ns/op	       0 B/op	       0 allocs/op
BenchmarkTime-8      	100000000	        16.6 ns/op	       1 B/op	       0 allocs/op
BenchmarkTime-8      	100000000	        15.4 ns/op	       1 B/op	       0 allocs/op
BenchmarkTime-8      	100000000	        15.6 ns/op	       1 B/op	       0 allocs/op
BenchmarkTime-8      	100000000	        15.6 ns/op	       1 B/op	       0 allocs/op
BenchmarkTime-8      	100000000	        14.9 ns/op	       1 B/op	       0 allocs/op
PASS
ok  	github.com/kpango/fastime	12.936s

Contribution

  1. Fork it ( https://github.com/kpango/fastime/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Author

kpango

LICENSE

fastime released under MIT license, refer LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormattedNow added in v1.0.4

func FormattedNow() []byte

FormattedNow returns formatted byte time

func Now

func Now() time.Time

Now returns current time

func Stop

func Stop()

Stop stops stopping time refresh daemon

func UnixNanoNow added in v1.0.1

func UnixNanoNow() int64

UnixNanoNow returns current unix nano time

func UnixNow added in v1.0.3

func UnixNow() int64

UnixNow returns current unix time

func UnixUNanoNow added in v1.0.2

func UnixUNanoNow() uint32

UnixNanoNow returns current unix nano time

func UnixUNow added in v1.0.3

func UnixUNow() uint32

UnixNow returns current unix time

Types

type Fastime

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

Fastime is fastime's base struct, it's stores atomic time object

func New

func New() *Fastime

New returns Fastime

func SetFormat added in v1.0.9

func SetFormat(format string) *Fastime

SetFormat replaces time format

func StartTimerD

func StartTimerD(ctx context.Context, dur time.Duration) *Fastime

StartTimerD provides time refresh daemon

func (*Fastime) FormattedNow added in v1.0.4

func (f *Fastime) FormattedNow() []byte

FormattedNow returns formatted byte time

func (*Fastime) Now

func (f *Fastime) Now() time.Time

Now returns current time

func (*Fastime) SetFormat added in v1.0.4

func (f *Fastime) SetFormat(format string) *Fastime

SetFormat replaces time format

func (*Fastime) StartTimerD

func (f *Fastime) StartTimerD(ctx context.Context, dur time.Duration) *Fastime

StartTimerD provides time refresh daemon

func (*Fastime) Stop

func (f *Fastime) Stop()

Stop stops stopping time refresh daemon

func (*Fastime) UnixNanoNow added in v1.0.1

func (f *Fastime) UnixNanoNow() int64

UnixNanoNow returns current unix nano time

func (*Fastime) UnixNow added in v1.0.3

func (f *Fastime) UnixNow() int64

UnixNow returns current unix time

func (*Fastime) UnixUNanoNow added in v1.0.2

func (f *Fastime) UnixUNanoNow() uint32

UnixNanoNow returns current unix nano time

func (*Fastime) UnixUNow added in v1.0.3

func (f *Fastime) UnixUNow() uint32

UnixNow returns current unix time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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