// compile with: dmd test.d -inline -O -release -w import std.stdio; import std.string; import std.c.windows.windows; struct Vector3f { float x, y, z; void opAddAssign(ref Vector3f v) { x += v.x; y += v.y; z += v.z; } Vector3f opMul(float s) { return Vector3f(x * s, y * s, z * s); } } int main(char[][] args) { long start, end, freq; QueryPerformanceFrequency(&freq); Vector3f v1 = {1.0f, 2.0f, 3.0f}; Vector3f v2 = {4.0f, 5.0f, 6.0f}; /* float t; asm { movss XMM1, t; }*/ QueryPerformanceCounter(&start); for (int i=0; i<0x40FFFFFF; i++) { // do something nontrivial... v2 += v1 * 3.0f; } QueryPerformanceCounter(&end); writefln("%.3fs", (end - start) / cast(float)freq); // to ensure that the compiler doesn't eliminate/optimize the inner loop writefln("(", v1.x, " ", v1.y, " ", v1.z, ") (", v2.x, " ", v2.y, " ", v2.z, ")"); return 0; }