1
0
mirror of synced 2025-11-06 03:20:55 +08:00
Files
SnowFlake-IdGenerator/ZeOthers/Vlang/source/test.v
2021-04-01 13:29:57 +08:00

31 lines
617 B
V
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)
}
}