Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/flyaways/timer

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/flyaways/timer

  • v1.0.1
  • Source
  • Go
  • Socket score

Version published
Created
Source

timer

Separated from https://github.com/TarsCloud/TarsGo/tree/master/tars/util/rtimer

for setDeadline and timeout sence ,but performance is better than TarsGo-rtimer.

Thanks a million to https://github.com/TarsCloud/TarsGo/tree/master/tars/util/rtimer

package main

import (
	"fmt"
	"time"
	"github.com/flyaways/timer"
)

func main() {
	t := timer.New(20, time.Second)
	defer t.Stop()

	done := make(chan struct{})
	go func() {
		//do something
		time.Sleep(time.Second)
		done <- struct{}{}
	}()

	select {
	case <-t.After(time.Second * 5):
		fmt.Println("after", time.Now().Format(time.RFC3339Nano))
	case <-done:
		fmt.Println("done", time.Now().Format(time.RFC3339Nano))
	}
}

Benchmark to FlyawaysTimer, TarsGoTimeWheel and OfficalTimer.

go test -count=1 -benchtime 5s -benchmem . -bench .
0.9948804265
goos: darwin
goarch: amd64
pkg: github.com/flyaways/timer
cpu: Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
BenchmarkFlyawaysTimer-4        174450506               53.58 ns/op            0 B/op          0 allocs/op
BenchmarkTarsGoTimer-4          79953462                74.30 ns/op            0 B/op          0 allocs/op
BenchmarkOfficalTimer-4         12491235               519.6 ns/op           201 B/op          3 allocs/op
BenchmarkRussellLuoTimer-4      13017769               514.1 ns/op           164 B/op          2 allocs/op
PASS
ok      github.com/flyaways/timer       43.342s

FAQs

Package last updated on 14 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc