mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
rename all timestamp function names from *Second to Timestamp*
This commit is contained in:
@ -100,53 +100,53 @@ func testConvert() {
|
||||
func testSplitChar() {
|
||||
var v interface{}
|
||||
j := gjson.New(nil)
|
||||
t1 := gtime.Nanosecond()
|
||||
t1 := gtime.TimestampNano()
|
||||
j.Set("a.b.c.d.e.f.g.h.i.j.k", 1)
|
||||
t2 := gtime.Nanosecond()
|
||||
t2 := gtime.TimestampNano()
|
||||
fmt.Println(t2 - t1)
|
||||
|
||||
t5 := gtime.Nanosecond()
|
||||
t5 := gtime.TimestampNano()
|
||||
v = j.Get("a.b.c.d.e.f.g.h.i.j.k")
|
||||
t6 := gtime.Nanosecond()
|
||||
t6 := gtime.TimestampNano()
|
||||
fmt.Println(v)
|
||||
fmt.Println(t6 - t5)
|
||||
|
||||
j.SetSplitChar('#')
|
||||
|
||||
t7 := gtime.Nanosecond()
|
||||
t7 := gtime.TimestampNano()
|
||||
v = j.Get("a#b#c#d#e#f#g#h#i#j#k")
|
||||
t8 := gtime.Nanosecond()
|
||||
t8 := gtime.TimestampNano()
|
||||
fmt.Println(v)
|
||||
fmt.Println(t8 - t7)
|
||||
}
|
||||
|
||||
func testViolenceCheck() {
|
||||
j := gjson.New(nil)
|
||||
t1 := gtime.Nanosecond()
|
||||
t1 := gtime.TimestampNano()
|
||||
j.Set("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", 1)
|
||||
t2 := gtime.Nanosecond()
|
||||
t2 := gtime.TimestampNano()
|
||||
fmt.Println(t2 - t1)
|
||||
|
||||
t3 := gtime.Nanosecond()
|
||||
t3 := gtime.TimestampNano()
|
||||
j.Set("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", 1)
|
||||
t4 := gtime.Nanosecond()
|
||||
t4 := gtime.TimestampNano()
|
||||
fmt.Println(t4 - t3)
|
||||
|
||||
t5 := gtime.Nanosecond()
|
||||
t5 := gtime.TimestampNano()
|
||||
j.Get("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a")
|
||||
t6 := gtime.Nanosecond()
|
||||
t6 := gtime.TimestampNano()
|
||||
fmt.Println(t6 - t5)
|
||||
|
||||
j.SetViolenceCheck(false)
|
||||
|
||||
t7 := gtime.Nanosecond()
|
||||
t7 := gtime.TimestampNano()
|
||||
j.Set("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", 1)
|
||||
t8 := gtime.Nanosecond()
|
||||
t8 := gtime.TimestampNano()
|
||||
fmt.Println(t8 - t7)
|
||||
|
||||
t9 := gtime.Nanosecond()
|
||||
t9 := gtime.TimestampNano()
|
||||
j.Get("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a")
|
||||
t10 := gtime.Nanosecond()
|
||||
t10 := gtime.TimestampNano()
|
||||
fmt.Println(t10 - t9)
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ func main() {
|
||||
s := g.Server()
|
||||
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||
g.GET("/set", func(r *ghttp.Request) {
|
||||
r.Session.Set("time", gtime.Second())
|
||||
r.Session.Set("time", gtime.Timestamp())
|
||||
r.Response.Write("ok")
|
||||
})
|
||||
g.GET("/get", func(r *ghttp.Request) {
|
||||
|
||||
@ -27,7 +27,7 @@ func main() {
|
||||
},
|
||||
MemUsed: 15560320,
|
||||
MemTotal: 16333788,
|
||||
Time: int(gtime.Second()),
|
||||
Time: int(gtime.Timestamp()),
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
start := gtime.Millisecond()
|
||||
start := gtime.TimestampMilli()
|
||||
wg := sync.WaitGroup{}
|
||||
for i := 0; i < 100000; i++ {
|
||||
wg.Add(1)
|
||||
@ -19,5 +19,5 @@ func main() {
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
fmt.Println("time spent:", gtime.Millisecond()-start)
|
||||
fmt.Println("time spent:", gtime.TimestampMilli()-start)
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
start := gtime.Millisecond()
|
||||
start := gtime.TimestampMilli()
|
||||
wg := sync.WaitGroup{}
|
||||
for i := 0; i < 100000; i++ {
|
||||
wg.Add(1)
|
||||
@ -21,5 +21,5 @@ func main() {
|
||||
}
|
||||
wg.Wait()
|
||||
fmt.Println(grpool.Size())
|
||||
fmt.Println("time spent:", gtime.Millisecond()-start)
|
||||
fmt.Println("time spent:", gtime.TimestampMilli()-start)
|
||||
}
|
||||
|
||||
@ -9,8 +9,8 @@ import (
|
||||
func main() {
|
||||
fmt.Println("Date :", gtime.Date())
|
||||
fmt.Println("Datetime :", gtime.Datetime())
|
||||
fmt.Println("Second :", gtime.Second())
|
||||
fmt.Println("Millisecond:", gtime.Millisecond())
|
||||
fmt.Println("Microsecond:", gtime.Microsecond())
|
||||
fmt.Println("Nanosecond :", gtime.Nanosecond())
|
||||
fmt.Println("Second :", gtime.Timestamp())
|
||||
fmt.Println("Millisecond:", gtime.TimestampMilli())
|
||||
fmt.Println("Microsecond:", gtime.TimestampMicro())
|
||||
fmt.Println("Nanosecond :", gtime.TimestampNano())
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ func (p *Pool) Put(value interface{}) {
|
||||
if p.Expire == 0 {
|
||||
item.expire = 0
|
||||
} else {
|
||||
item.expire = gtime.Millisecond() + p.Expire
|
||||
item.expire = gtime.TimestampMilli() + p.Expire
|
||||
}
|
||||
p.list.PushBack(item)
|
||||
}
|
||||
@ -86,7 +86,7 @@ func (p *Pool) Get() (interface{}, error) {
|
||||
for !p.closed.Val() {
|
||||
if r := p.list.PopFront(); r != nil {
|
||||
f := r.(*poolItem)
|
||||
if f.expire == 0 || f.expire > gtime.Millisecond() {
|
||||
if f.expire == 0 || f.expire > gtime.TimestampMilli() {
|
||||
return f.value, nil
|
||||
}
|
||||
} else {
|
||||
@ -130,7 +130,7 @@ func (p *Pool) checkExpire() {
|
||||
// TODO Do not use Pop and Push mechanism, which is not graceful.
|
||||
if r := p.list.PopFront(); r != nil {
|
||||
item := r.(*poolItem)
|
||||
if item.expire == 0 || item.expire > gtime.Millisecond() {
|
||||
if item.expire == 0 || item.expire > gtime.TimestampMilli() {
|
||||
p.list.PushFront(item)
|
||||
break
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ func Test_Conn(t *testing.T) {
|
||||
conn := redis.Conn()
|
||||
defer conn.Close()
|
||||
|
||||
key := gconv.String(gtime.Nanosecond())
|
||||
key := gconv.String(gtime.TimestampNano())
|
||||
value := []byte("v")
|
||||
r, err := conn.Do("SET", key, value)
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
@ -112,7 +112,7 @@ test = "v=1"
|
||||
|
||||
// absolute path
|
||||
gtest.Case(t, func() {
|
||||
path := fmt.Sprintf(`%s/%d`, gfile.TempDir(), gtime.Nanosecond())
|
||||
path := fmt.Sprintf(`%s/%d`, gfile.TempDir(), gtime.TimestampNano())
|
||||
file := fmt.Sprintf(`%s/%s`, path, "config.toml")
|
||||
err := gfile.PutContents(file, config)
|
||||
gtest.Assert(err, nil)
|
||||
@ -126,7 +126,7 @@ test = "v=1"
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
||||
gtest.Case(t, func() {
|
||||
path := fmt.Sprintf(`%s/%d/config`, gfile.TempDir(), gtime.Nanosecond())
|
||||
path := fmt.Sprintf(`%s/%d/config`, gfile.TempDir(), gtime.TimestampNano())
|
||||
file := fmt.Sprintf(`%s/%s`, path, "config.toml")
|
||||
err := gfile.PutContents(file, config)
|
||||
gtest.Assert(err, nil)
|
||||
@ -140,7 +140,7 @@ test = "v=1"
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
||||
gtest.Case(t, func() {
|
||||
path := fmt.Sprintf(`%s/%d`, gfile.TempDir(), gtime.Nanosecond())
|
||||
path := fmt.Sprintf(`%s/%d`, gfile.TempDir(), gtime.TimestampNano())
|
||||
file := fmt.Sprintf(`%s/%s`, path, "test.toml")
|
||||
err := gfile.PutContents(file, config)
|
||||
gtest.Assert(err, nil)
|
||||
@ -155,7 +155,7 @@ test = "v=1"
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
|
||||
gtest.Case(t, func() {
|
||||
path := fmt.Sprintf(`%s/%d/config`, gfile.TempDir(), gtime.Nanosecond())
|
||||
path := fmt.Sprintf(`%s/%d/config`, gfile.TempDir(), gtime.TimestampNano())
|
||||
file := fmt.Sprintf(`%s/%s`, path, "test.toml")
|
||||
err := gfile.PutContents(file, config)
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
@ -35,7 +35,7 @@ func Test_View(t *testing.T) {
|
||||
gtest.Assert(b, "中国人")
|
||||
})
|
||||
gtest.Case(t, func() {
|
||||
path := fmt.Sprintf(`%s/%d`, gfile.TempDir(), gtime.Nanosecond())
|
||||
path := fmt.Sprintf(`%s/%d`, gfile.TempDir(), gtime.TimestampNano())
|
||||
tpl := fmt.Sprintf(`%s/%s`, path, "t.tpl")
|
||||
err := gfile.PutContents(tpl, `{{"我是中国人" | substr 2 -1}}`)
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
@ -123,7 +123,7 @@ func Test_Instance(t *testing.T) {
|
||||
})
|
||||
|
||||
gtest.Case(t, func() {
|
||||
m := gi18n.Instance(gconv.String(gtime.Nanosecond()))
|
||||
m := gi18n.Instance(gconv.String(gtime.TimestampNano()))
|
||||
gtest.Assert(m.T("{#hello}{#world}"), "{#hello}{#world}")
|
||||
})
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ type utilAdmin struct{}
|
||||
var serverActionLocker sync.Mutex
|
||||
|
||||
// (进程级别)用于记录上一次操作的时间(毫秒)
|
||||
var serverActionLastTime = gtype.NewInt64(gtime.Millisecond())
|
||||
var serverActionLastTime = gtype.NewInt64(gtime.TimestampMilli())
|
||||
|
||||
// 当前服务进程所处的互斥管理操作状态
|
||||
var serverProcessStatus = gtype.NewInt()
|
||||
@ -93,11 +93,11 @@ func checkProcessStatus() error {
|
||||
|
||||
// 检测当前操作的频繁度
|
||||
func checkActionFrequence() error {
|
||||
interval := gtime.Millisecond() - serverActionLastTime.Val()
|
||||
interval := gtime.TimestampMilli() - serverActionLastTime.Val()
|
||||
if interval < gADMIN_ACTION_INTERVAL_LIMIT {
|
||||
return errors.New(fmt.Sprintf("too frequent action, please retry in %d ms", gADMIN_ACTION_INTERVAL_LIMIT-interval))
|
||||
}
|
||||
serverActionLastTime.Set(gtime.Millisecond())
|
||||
serverActionLastTime.Set(gtime.TimestampMilli())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -101,7 +101,7 @@ func (c *Cookie) SetCookie(key, value, domain, path string, maxAge time.Duration
|
||||
isHttpOnly = httpOnly[0]
|
||||
}
|
||||
c.data[key] = CookieItem{
|
||||
value, domain, path, gtime.Second() + int64(maxAge.Seconds()), isHttpOnly,
|
||||
value, domain, path, gtime.Timestamp() + int64(maxAge.Seconds()), isHttpOnly,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -143,7 +143,7 @@ func (c *memCache) doSetWithLockCheck(key interface{}, value interface{}, durati
|
||||
// getInternalExpire returns the expire time with given expire duration in milliseconds.
|
||||
func (c *memCache) getInternalExpire(expire int64) int64 {
|
||||
if expire != 0 {
|
||||
return gtime.Millisecond() + expire
|
||||
return gtime.TimestampMilli() + expire
|
||||
} else {
|
||||
return gDEFAULT_MAX_EXPIRE
|
||||
}
|
||||
@ -179,7 +179,7 @@ func (c *memCache) Get(key interface{}) interface{} {
|
||||
item, ok := c.data[key]
|
||||
c.dataMu.RUnlock()
|
||||
if ok && !item.IsExpired() {
|
||||
// Adding to LRU history if LRU feature is enbaled.
|
||||
// Adding to LRU history if LRU feature is enabled.
|
||||
if c.cap > 0 {
|
||||
c.lruGetList.PushBack(key)
|
||||
}
|
||||
@ -238,7 +238,7 @@ func (c *memCache) Remove(key interface{}) (value interface{}) {
|
||||
c.dataMu.Lock()
|
||||
delete(c.data, key)
|
||||
c.dataMu.Unlock()
|
||||
c.eventList.PushBack(&memCacheEvent{k: key, e: gtime.Millisecond() - 1000})
|
||||
c.eventList.PushBack(&memCacheEvent{k: key, e: gtime.TimestampMilli() - 1000})
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -365,7 +365,7 @@ func (c *memCache) syncEventAndClearExpired() {
|
||||
// ========================
|
||||
// Data Cleaning up.
|
||||
// ========================
|
||||
ek := c.makeExpireKey(gtime.Millisecond())
|
||||
ek := c.makeExpireKey(gtime.TimestampMilli())
|
||||
eks := []int64{ek - 1000, ek - 2000, ek - 3000, ek - 4000, ek - 5000}
|
||||
for _, expireTime := range eks {
|
||||
if expireSet := c.getExpireSet(expireTime); expireSet != nil {
|
||||
|
||||
@ -14,7 +14,7 @@ import (
|
||||
func (item *memCacheItem) IsExpired() bool {
|
||||
// Note that it should use greater than or equal judgement here
|
||||
// imagining that the cache time is only 1 millisecond.
|
||||
if item.e >= gtime.Millisecond() {
|
||||
if item.e >= gtime.TimestampMilli() {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
@ -24,7 +24,7 @@ func Test_GEnv_All(t *testing.T) {
|
||||
|
||||
func Test_GEnv_Map(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
value := gconv.String(gtime.Nanosecond())
|
||||
value := gconv.String(gtime.TimestampNano())
|
||||
key := "TEST_ENV_" + value
|
||||
err := os.Setenv(key, "TEST")
|
||||
gtest.Assert(err, nil)
|
||||
@ -34,7 +34,7 @@ func Test_GEnv_Map(t *testing.T) {
|
||||
|
||||
func Test_GEnv_Get(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
value := gconv.String(gtime.Nanosecond())
|
||||
value := gconv.String(gtime.TimestampNano())
|
||||
key := "TEST_ENV_" + value
|
||||
err := os.Setenv(key, "TEST")
|
||||
gtest.Assert(err, nil)
|
||||
@ -44,7 +44,7 @@ func Test_GEnv_Get(t *testing.T) {
|
||||
|
||||
func Test_GEnv_Contains(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
value := gconv.String(gtime.Nanosecond())
|
||||
value := gconv.String(gtime.TimestampNano())
|
||||
key := "TEST_ENV_" + value
|
||||
err := os.Setenv(key, "TEST")
|
||||
gtest.Assert(err, nil)
|
||||
@ -55,7 +55,7 @@ func Test_GEnv_Contains(t *testing.T) {
|
||||
|
||||
func Test_GEnv_Set(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
value := gconv.String(gtime.Nanosecond())
|
||||
value := gconv.String(gtime.TimestampNano())
|
||||
key := "TEST_ENV_" + value
|
||||
err := genv.Set(key, "TEST")
|
||||
gtest.Assert(err, nil)
|
||||
@ -76,7 +76,7 @@ func Test_GEnv_Build(t *testing.T) {
|
||||
|
||||
func Test_GEnv_Remove(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
value := gconv.String(gtime.Nanosecond())
|
||||
value := gconv.String(gtime.TimestampNano())
|
||||
key := "TEST_ENV_" + value
|
||||
err := os.Setenv(key, "TEST")
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
@ -34,7 +34,7 @@ func Test_IsDir(t *testing.T) {
|
||||
|
||||
func Test_IsEmpty(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
path := "/testdir_" + gconv.String(gtime.Nanosecond())
|
||||
path := "/testdir_" + gconv.String(gtime.TimestampNano())
|
||||
createDir(path)
|
||||
defer delTestFiles(path)
|
||||
|
||||
@ -42,14 +42,14 @@ func Test_IsEmpty(t *testing.T) {
|
||||
gtest.Assert(gfile.IsEmpty(testpath()+path+gfile.Separator+"test.txt"), true)
|
||||
})
|
||||
gtest.Case(t, func() {
|
||||
path := "/testfile_" + gconv.String(gtime.Nanosecond())
|
||||
path := "/testfile_" + gconv.String(gtime.TimestampNano())
|
||||
createTestFile(path, "")
|
||||
defer delTestFiles(path)
|
||||
|
||||
gtest.Assert(gfile.IsEmpty(testpath()+path), true)
|
||||
})
|
||||
gtest.Case(t, func() {
|
||||
path := "/testfile_" + gconv.String(gtime.Nanosecond())
|
||||
path := "/testfile_" + gconv.String(gtime.TimestampNano())
|
||||
createTestFile(path, "1")
|
||||
defer delTestFiles(path)
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
func TestWatcher_AddOnce(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
value := gtype.New()
|
||||
path := gfile.Join(gfile.TempDir(), gconv.String(gtime.Nanosecond()))
|
||||
path := gfile.Join(gfile.TempDir(), gconv.String(gtime.TimestampNano()))
|
||||
err := gfile.PutContents(path, "init")
|
||||
gtest.Assert(err, nil)
|
||||
defer gfile.Remove(path)
|
||||
@ -56,8 +56,8 @@ func TestWatcher_AddOnce(t *testing.T) {
|
||||
|
||||
func TestWatcher_AddRemove(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.Nanosecond())
|
||||
path2 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.Nanosecond()) + "2"
|
||||
path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.TimestampNano())
|
||||
path2 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.TimestampNano()) + "2"
|
||||
gfile.PutContents(path1, "1")
|
||||
defer func() {
|
||||
gfile.Remove(path1)
|
||||
@ -88,7 +88,7 @@ func TestWatcher_AddRemove(t *testing.T) {
|
||||
})
|
||||
|
||||
gtest.Case(t, func() {
|
||||
path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.Nanosecond())
|
||||
path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.TimestampNano())
|
||||
gfile.PutContents(path1, "1")
|
||||
defer func() {
|
||||
gfile.Remove(path1)
|
||||
@ -123,7 +123,7 @@ func TestWatcher_AddRemove(t *testing.T) {
|
||||
|
||||
func TestWatcher_Callback(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.Nanosecond())
|
||||
path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.TimestampNano())
|
||||
gfile.PutContents(path1, "1")
|
||||
defer func() {
|
||||
gfile.Remove(path1)
|
||||
@ -150,7 +150,7 @@ func TestWatcher_Callback(t *testing.T) {
|
||||
})
|
||||
// multiple callbacks
|
||||
gtest.Case(t, func() {
|
||||
path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.Nanosecond())
|
||||
path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.TimestampNano())
|
||||
gfile.PutContents(path1, "1")
|
||||
defer func() {
|
||||
gfile.Remove(path1)
|
||||
|
||||
@ -23,5 +23,5 @@ var (
|
||||
// NewSessionId creates and returns a new and unique session id string,
|
||||
// the length of which is 18 bytes.
|
||||
func NewSessionId() string {
|
||||
return strings.ToUpper(strconv.FormatInt(gtime.Nanosecond(), 36) + grand.Str(6))
|
||||
return strings.ToUpper(strconv.FormatInt(gtime.TimestampNano(), 36) + grand.Str(6))
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ func (s *StorageFile) GetSession(id string, ttl time.Duration, data *gmap.StrAny
|
||||
content := gfile.GetBytes(path)
|
||||
if len(content) > 8 {
|
||||
timestampMilli := gbinary.DecodeToInt64(content[:8])
|
||||
if timestampMilli+ttl.Nanoseconds()/1e6 < gtime.Millisecond() {
|
||||
if timestampMilli+ttl.Nanoseconds()/1e6 < gtime.TimestampMilli() {
|
||||
return nil, nil
|
||||
}
|
||||
var err error
|
||||
@ -211,7 +211,7 @@ func (s *StorageFile) SetSession(id string, data *gmap.StrAnyMap, ttl time.Durat
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
if _, err = file.Write(gbinary.EncodeInt64(gtime.Millisecond())); err != nil {
|
||||
if _, err = file.Write(gbinary.EncodeInt64(gtime.TimestampMilli())); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err = file.Write(content); err != nil {
|
||||
@ -239,7 +239,7 @@ func (s *StorageFile) doUpdateTTL(id string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err = file.WriteAt(gbinary.EncodeInt64(gtime.Millisecond()), 0); err != nil {
|
||||
if _, err = file.WriteAt(gbinary.EncodeInt64(gtime.TimestampMilli()), 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return file.Close()
|
||||
|
||||
@ -14,25 +14,25 @@ import (
|
||||
|
||||
func Benchmark_Second(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
gtime.Second()
|
||||
gtime.Timestamp()
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Millisecond(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
gtime.Millisecond()
|
||||
gtime.TimestampMilli()
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Microsecond(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
gtime.Microsecond()
|
||||
gtime.TimestampMicro()
|
||||
}
|
||||
}
|
||||
|
||||
func Benchmark_Nanosecond(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
gtime.Nanosecond()
|
||||
gtime.TimestampNano()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ func Test_SetTimeZone(t *testing.T) {
|
||||
|
||||
func Test_Nanosecond(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
nanos := gtime.Nanosecond()
|
||||
nanos := gtime.TimestampNano()
|
||||
timeTemp := time.Unix(0, nanos)
|
||||
gtest.Assert(nanos, timeTemp.UnixNano())
|
||||
})
|
||||
@ -31,7 +31,7 @@ func Test_Nanosecond(t *testing.T) {
|
||||
|
||||
func Test_Microsecond(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
micros := gtime.Microsecond()
|
||||
micros := gtime.TimestampMicro()
|
||||
timeTemp := time.Unix(0, micros*1e3)
|
||||
gtest.Assert(micros, timeTemp.UnixNano()/1e3)
|
||||
})
|
||||
@ -39,7 +39,7 @@ func Test_Microsecond(t *testing.T) {
|
||||
|
||||
func Test_Millisecond(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
millis := gtime.Millisecond()
|
||||
millis := gtime.TimestampMilli()
|
||||
timeTemp := time.Unix(0, millis*1e6)
|
||||
gtest.Assert(millis, timeTemp.UnixNano()/1e6)
|
||||
})
|
||||
@ -47,7 +47,7 @@ func Test_Millisecond(t *testing.T) {
|
||||
|
||||
func Test_Second(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
s := gtime.Second()
|
||||
s := gtime.Timestamp()
|
||||
timeTemp := time.Unix(s, 0)
|
||||
gtest.Assert(s, timeTemp.Unix())
|
||||
})
|
||||
|
||||
@ -281,7 +281,7 @@ func Test_HotReload(t *testing.T) {
|
||||
dirPath := gfile.Join(
|
||||
gfile.TempDir(),
|
||||
"testdata",
|
||||
"template-"+gconv.String(gtime.Nanosecond()),
|
||||
"template-"+gconv.String(gtime.TimestampNano()),
|
||||
)
|
||||
defer gfile.Remove(dirPath)
|
||||
filePath := gfile.Join(dirPath, "test.html")
|
||||
|
||||
Reference in New Issue
Block a user