fix #16752: threadvar now works with importcpp types; osx now uses native TLS (--tlsEmulation:off), which can be orders of magnitude faster (#16750)
* osx now uses native TLS, which can be orders of magnitude faster
* add {.cppNonPod.}
* improve test
* changelog, docs, disable part of windows test
This commit is contained in:
parent
3c8fddbc76
commit
e112974920
13 changed files with 194 additions and 13 deletions
5
tests/benchmarks/readme.md
Normal file
5
tests/benchmarks/readme.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Collection of benchmarks
|
||||
|
||||
In future work, benchmarks can be added to CI, but for now we provide benchmarks that can be run locally.
|
||||
|
||||
See RFC: https://github.com/timotheecour/Nim/issues/425
|
||||
30
tests/benchmarks/ttls.nim
Normal file
30
tests/benchmarks/ttls.nim
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
discard """
|
||||
action: compile
|
||||
"""
|
||||
|
||||
#[
|
||||
## on osx
|
||||
nim r -d:danger --threads --tlsEmulation:off tests/benchmarks/ttls.nim
|
||||
9.999999999992654e-07
|
||||
|
||||
ditto with `--tlsEmulation:on`:
|
||||
0.216999
|
||||
]#
|
||||
|
||||
import times
|
||||
|
||||
proc main2(): int =
|
||||
var g0 {.threadvar.}: int
|
||||
g0.inc
|
||||
result = g0
|
||||
|
||||
proc main =
|
||||
let n = 100_000_000
|
||||
var c = 0
|
||||
let t = cpuTime()
|
||||
for i in 0..<n:
|
||||
c += main2()
|
||||
let t2 = cpuTime() - t
|
||||
doAssert c != 0
|
||||
echo t2
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue