Quick actions

cmd+k|ctrl+k

Navigation

Languages

Untitled

Snippet info

Language

Nim

Visibility

unlisted

Author

legacy-anonymous

Created

2017-06-01T10:30:55Z

Updated

2017-06-01T10:30:55Z

import tables, times, random

var
  table = initTable[int, int]()
  t1, t2: float

const loops = 10_000
randomize(1234)
t1 = cpuTime()
for _ in 0..<loops:
  let i = random(high(int))
  table.add(i, i)
echo "add ", cpuTime() - t1 # displays 0.002

randomize(1234)
t1 = cpuTime()
for _ in 0..<loops:
  table.del(random(high(int)))
echo "del ", cpuTime() - t1 # displays 1.313
INFO