std.variant benchmark
Dmitry Olshansky
dmitry.olsh at gmail.com
Sun Jul 29 13:24:40 PDT 2012
On 30-Jul-12 00:11, Dmitry Olshansky wrote:
> I've found something far more evil:
>
> @property bool convertsTo(T)() const
> {
> TypeInfo info = typeid(T);
> return fptr(OpID.testConversion, null, &info) == 0;
> }
>
> Okay... now let me pull off another piece of rag:
>
> private VariantN opArithmetic(T, string op)(T other)
> {
> VariantN result;
> static if (is(T == VariantN))
> {
> /*if (convertsTo!(uint) && other.convertsTo!(uint))
> result = mixin("get!(uint) " ~ op ~ " other.get!(uint)");
> else*/ if (convertsTo!(int) && other.convertsTo!(int))
> result = mixin("get!(int) " ~ op ~ " other.get!(int)");
...
Apparently I'm spot on.
Just commenting one extra branch of this horror movie
gives interesting change:
2779us
2667us
3153762us
After:
2319us
2523us
288581us
Aye, 10x :o)
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list