<div class="gmail_quote">On Mon, Jul 30, 2012 at 6:07 AM, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org" target="_blank">SeeWebsiteForEmail@erdani.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 7/29/12 11:20 AM, Gor Gyolchanyan wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On Sun, Jul 29, 2012 at 6:43 PM, Dmitry Olshansky <<a href="mailto:dmitry.olsh@gmail.com" target="_blank">dmitry.olsh@gmail.com</a><br></div><div class="im">
<mailto:<a href="mailto:dmitry.olsh@gmail.com" target="_blank">dmitry.olsh@gmail.com</a>><u></u>> wrote:<br>
    This should be more relevant then:<br>
<br>
    //fib.d<br>
    import std.datetime, std.stdio, std.variant;<br>
<br>
    auto fib(Int)()<br>
    {<br>
             Int a = 1, b = 1;<br>
             for(size_t i=0; i<100; i++){<br>
                     Int c = a + b;<br>
                     a = b;<br>
                     b = c;<br>
             }<br>
             return a;<br>
    }<br>
<br>
    void main()<br>
    {<br>
             writeln(benchmark!(fib!int, fib!long, fib!Variant)(10_000));<br>
    }<br>
<br>
<br>
    dmd -O -inline -release fib.d<br>
<br>
    Output:<br>
<br>
    [TickDuration(197), TickDuration(276), TickDuration(93370107)]<br>
<br>
    I'm horrified. Who was working on std.variant enhancements? Please<br>
    chime in.<br>
<br>
    --<br>
    Dmitry Olshansky<br>
<br>
<br></div><div class="im">
Thank you for demonstrating my point. :-)<br>
</div></blockquote>
<br>
I don't think he demonstrated your point (even leaving aside that the benchmark above is also flawed). I don't think there was a point, unless it was you wanted to vent and looked for a pretext - which is, by the way, entirely reasonable.<br>

<br>
You mentioned you need "a very fast typeless storage with maximum performance and type safety." Well if it's typeless then it means you're using it for storage, not for computationally-intensive operations, as the code above does. So what you'd presumably want to test is the speed of data storage and retrieval. A loop that does a bunch of adds on Variant does not go in that direction.<br>

<br>
Benchmarks are notoriously hard to get right. You need to think of reasonable baselines - if you want to use Variant for typeless storage, what is your vanilla implementation, the "obvious contender"? What are the primitives of which speed is important? Then you need to make sure you subtract noise from all your comparisons. Then you need to figure whether the issue is with the design or with the implementation of Variant. In the former case, maybe Variant isn't for you. In the latter, bug reports are always welcome.<span class="HOEnZb"><font color="#888888"><br>

<br>
<br>
Andrei<br>
</font></span></blockquote></div><br>You're right. I'm trying to make a subject-oriented system, where there are nodes and accessors and each accessor has access to a specific part of the node. I must have the data stored in typeless manner and cast to the appropriate type (depending on the accessor). This is all necessary for my very flexible graph data structure.<br clear="all">
<div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>