std.variant benchmark
Gor Gyolchanyan
gor.f.gyolchanyan at gmail.com
Sun Jul 29 05:17:11 PDT 2012
std.variant is so incredibly slow! It's practically unusable for anything,
which requires even a tiny bit of performance.
Benchmark done under -noboundscheck -inline -release -O:
import std.stdio;
import std.variant;
import std.datetime;
void on()
{
auto var = Variant(5);
int i = var.get!int;
}
void off()
{
auto var = 5;
int i = var;
}
void main()
{
writeln(benchmark!(on, off)(100000));
}
The result is:
[TickDuration(25094), TickDuration(98)]
There are tons of cases, where a simple typeless data storage is necessary.
No type information, no type checking - just a low-level storage, upon
which Variant and other dynamic-type constructs can be built.
I want to ask the community: what's the best way to store any variable in a
typeless storage, so that one could store any variable in that storage and
get a reference to that variable given its static type with no type
checking and minimal overhead compared to a statically typed storage and
with type-safe storage (postblits, garbage collection...)?
--
Bye,
Gor Gyolchanyan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120729/888da7a1/attachment-0001.html>
More information about the Digitalmars-d
mailing list