fastime

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: MIT Imports: 7 Imported by: 1

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

func FormattedNow() []byte

FormattedNow returns formatted byte time

func GetFormat

func GetFormat() string

func GetLocation

func GetLocation() *time.Location

func IsDaemonRunning

func IsDaemonRunning() bool

func Now

func Now() time.Time

Now returns current time

func Stop

func Stop()

Stop stops stopping time refresh daemon

func UnixNanoNow

func UnixNanoNow() int64

UnixNanoNow returns current unix nano time

func UnixNow

func UnixNow() int64

UnixNow returns current unix time

func UnixUNanoNow

func UnixUNanoNow() uint32

UnixUNanoNow returns current unix nano time

func UnixUNow

func UnixUNow() uint32

UnixUNow returns current unix time

Types

type Fastime

type Fastime interface {
	IsDaemonRunning() bool
	GetFormat() string
	SetFormat(format string) Fastime
	GetLocation() *time.Location
	SetLocation(location *time.Location) Fastime
	Now() time.Time
	Stop()
	UnixNow() int64
	UnixUNow() uint32
	UnixNanoNow() int64
	UnixUNanoNow() uint32
	FormattedNow() []byte
	StartTimerD(ctx context.Context, dur time.Duration) Fastime
}

func New

func New() Fastime

New returns Fastime

func SetFormat

func SetFormat(format string) Fastime

SetFormat replaces time format

func SetLocation

func SetLocation(location *time.Location) Fastime

SetLocation replaces time location

func StartTimerD

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

StartTimerD provides time refresh daemon

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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