ttls.nim 434 B

12345678910111213141516171819202122232425262728293031
  1. discard """
  2. action: compile
  3. """
  4. #[
  5. ## on osx
  6. nim r -d:danger --threads --tlsEmulation:off tests/benchmarks/ttls.nim
  7. 9.999999999992654e-07
  8. ditto with `--tlsEmulation:on`:
  9. 0.216999
  10. ]#
  11. import times
  12. proc main2(): int =
  13. var g0 {.threadvar.}: int
  14. g0.inc
  15. result = g0
  16. proc main =
  17. let n = 100_000_000
  18. var c = 0
  19. let t = cpuTime()
  20. for i in 0..<n:
  21. c += main2()
  22. let t2 = cpuTime() - t
  23. doAssert c != 0
  24. echo t2
  25. main()