1
0
mirror of synced 2026-04-17 22:08:39 +08:00

auto commit

This commit is contained in:
yitter
2021-04-01 13:29:57 +08:00
parent 9c7f4fb115
commit 09ddeccef5
11 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
module main
import time
import contract
import gen
fn main(){
// 方法一直接采用默认方法生成一个Id
yid := gen.YitIdHelper{
id_gen: gen.make_generator(&contract.IdGeneratorOptions{
method: 1
base_time: 1582136402000
workerid_bitlength:6
seq_bitlength:6
})
}
println(yid.next_id())
// 方法二自定义参数
times := 50000
for {
begin := time.now().unix_time_milli()
for i := 0; i < times; i++ {
yid.next_id()
}
end := time.now().unix_time_milli()
println("漂移,总共:"+times.str()+""+(end-begin).str()+" ms")
time.sleep(1 * time.second)
}
}