{
{
NI i;
NI res;
i = (NI)0;
res = ((NI)1);
{
while (1) {
Who knows what you are measuring.
ok, bad example. why then my first JsonNode example also shows worse perfomance
when there is additional iterator in between? JsonNode as i know is ref
JsonNodeObj so there should not be a copy
Who knows what you are measuring.
is it not enabled by default when compiled with -d:release -d:danger?
Inlining is not the same as copy elision, these iterators are inlined. Also,
turn on the optimizer.
Found that use of iterator which just extend field is cost additional
computation time (about 20% time more)
nim
import std/[json, times, monotimes, tables]
let a = %*{"a": 1, "b": 2, "c": 3}
var start = getMonoTime()
for i in 1..1_000_000:
for k, v in a.f
have managed to simplify
type A = object
a: int
b: int
iterator q1(): A =
for i in 1..1_000_000:
yield A(a: i)
iterator q2(): A =
for i in q1():
yield i
var b = 0
start = getMonoTime()
for i in q1():
b += i
have managed to simplify
type A = object
a: int
b: int
iterator q1(): A =
for i in 1..1_000_000:
yield A(a: i)
iterator q2(): A =
for i in q1():
yield i
var b = 0
start = getMonoTime()
for i in q1():
b += i