Method template optimization that works in C++, but not very well D
Ali Çehreli
acehreli at yahoo.com
Thu Feb 20 14:36:57 PST 2014
On 02/19/2014 10:18 PM, Vladimir wrote:
>> Full version my very simplified example such task:
>> https://gist.github.com/Vladimir-Z/1a1755ce91cb0e7636b5
Notes:
* It is "process", not "proccess". :)
* isUseField is not used by proccessRowTemplate(). Removing it from the
parameter list (and doing necessary modifications elsewhere) reduced the
optimized time from 18ms to 15ms for me.
* Applied ^^ operator for proccessRowTemplate as well. (No effect on
performance.)
* I liked the simple template syntax for proccessRowTemplate:
int proccessRowTemplate(size_t optionVariant)(in Row table)
{
int sum = 0;
foreach(size_t i; StaticRange!(Row.numberField))
{
static if (optionVariant & 1<<i)
{
sum += table.Fields[i] ^^ 2 - i;
}
}
return sum;
}
Results on my system after that change:
Process table result: 142459540
Simple processing: 35 ms
Process table result: 142459540
Template processing: 15 ms
Ali
More information about the Digitalmars-d-learn
mailing list