fastime

package module
v1.0.18 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: MIT Imports: 8 Imported by: 52

README

release CircleCI codecov Codacy Badge Go Report Card GoDoc fastime is a super fast time function library for Go with zero memory allocation. fastime returns the approximate time.

Requirement

Go 1.16

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=10 -run=NONE -bench . -benchmem
goos: linux
goarch: amd64
pkg: github.com/kpango/fastime
BenchmarkFastime-8   	2000000000	         0.45 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastime-8   	2000000000	         0.45 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastime-8   	2000000000	         0.45 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastime-8   	2000000000	         0.45 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastime-8   	2000000000	         0.45 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastime-8   	2000000000	         0.45 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastime-8   	2000000000	         0.45 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastime-8   	2000000000	         0.45 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastime-8   	2000000000	         0.45 ns/op	       0 B/op	       0 allocs/op
BenchmarkFastime-8   	2000000000	         0.46 ns/op	       0 B/op	       0 allocs/op
BenchmarkTime-8      	 1000000	      1683 ns/op	       0 B/op	       0 allocs/op
BenchmarkTime-8      	 1000000	      1720 ns/op	       0 B/op	       0 allocs/op
BenchmarkTime-8      	 1000000	      1688 ns/op	       0 B/op	       0 allocs/op
BenchmarkTime-8      	 1000000	      1716 ns/op	       0 B/op	       0 allocs/op
BenchmarkTime-8      	 1000000	      1691 ns/op	       0 B/op	       0 allocs/op
BenchmarkTime-8      	 1000000	      1693 ns/op	       0 B/op	       0 allocs/op
BenchmarkTime-8      	 1000000	      1703 ns/op	       0 B/op	       0 allocs/op
BenchmarkTime-8      	 1000000	      1668 ns/op	       0 B/op	       0 allocs/op
BenchmarkTime-8      	 1000000	      1685 ns/op	       0 B/op	       0 allocs/op
BenchmarkTime-8      	 1000000	      1716 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/kpango/fastime	26.873s

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