import std.stdio; import std.math; import std.perf; struct Old { float a; float b; } struct New { float a; float b; float c; float d; } class Foo { void run(Old a) { exp(a.a); } void run(Old a, Old b) { exp(a.a); } void run(Old a, Old b, Old c) { exp(a.a); // exp(b.a); // exp(c.a); } void run(New a) { exp(a.a); } void run(New a, New b) { exp(a.a); } void run(New a, New b, New c) { exp(a.a); // exp(b.a); // exp(c.a); } } void run(Old a) { exp(a.a); } void run(Old a, Old b) { exp(a.a); } void run(Old a, Old b, Old c) { exp(a.a); } void run(New a) { exp(a.a); } void run(New a, New b) { exp(a.a); } void run(New a, New b, New c) { exp(a.a); } int main(char[][] args) { scope foo = new Foo(); Old a1,a2,a3,a4; New b1,b2,b3; a1.a = 5; a3 = a1; a2 = a1; b1.a = 5; b2 = b1; b3 = b1; a1.a = 10; a1.b = 12; b1.a = 10; b1.d = 12; auto c1 = new New; auto c2 = new New; *c1 = b1; /* asm { movups XMM0, b1 ; //movdqa , movups, movaps movups b2, XMM0; } writefln(b1.a," ",b2.a); writefln(b1.d," ",b2.d); return 0; */ auto hpc = new HighPerformanceCounter(); uint count = 100_000; long loop_time = long.max; long old_time = long.max; long new_time = long.max; for(uint t = 0; t < 100; t++) { hpc.start; for(uint i = 0; i < count; i++) { } hpc.stop; if( hpc.microseconds < loop_time ) loop_time = hpc.microseconds; hpc.start; for(uint i = 0; i < count; i++) { //* a2 = a1; a2 = a1; a2 = a1; a2 = a1; a2 = a1; a2 = a1; a2 = a1; a2 = a1; a2 = a1; a2 = a1; /*/ asm { movq XMM0, a1 ; movq a2, XMM0; } asm { movq XMM0, a1 ; movq a2, XMM0; } asm { movq XMM0, a1 ; movq a2, XMM0; } asm { movq XMM0, a1 ; movq a2, XMM0; } asm { movq XMM0, a1 ; movq a2, XMM0; } asm { movq XMM0, a1 ; movq a2, XMM0; } asm { movq XMM0, a1 ; movq a2, XMM0; } asm { movq XMM0, a1 ; movq a2, XMM0; } asm { movq XMM0, a1 ; movq a2, XMM0; } asm { movq XMM0, a1 ; movq a2, XMM0; } asm { movq XMM0, a1 ; movq a2, XMM0; } //*/ // foo.run(a1);//,a2,a3); } hpc.stop; if( hpc.microseconds < old_time ) old_time = hpc.microseconds; hpc.start; for(uint i = 0; i < count; i++) { /* asm { movq XMM0, b1 ; movq b2, XMM0; } asm { movq XMM0, b1 ; movq b2, XMM0; } asm { movq XMM0, b1 ; movq b2, XMM0; } asm { movq XMM0, b1 ; movq b2, XMM0; } asm { movq XMM0, b1 ; movq b2, XMM0; } asm { movq XMM0, b1 ; movq b2, XMM0; } asm { movq XMM0, b1 ; movq b2, XMM0; } asm { movq XMM0, b1 ; movq b2, XMM0; } asm { movq XMM0, b1 ; movq b2, XMM0; } asm { movq XMM0, b1 ; movq b2, XMM0; } asm { movq XMM0, b1 ; movq b2, XMM0; } //*/ asm { movq XMM0, b1 ; movq XMM1, b1 ; movq b2, XMM0; movq b2, XMM1;} asm { movq XMM0, b1 ; movq XMM1, b1 ; movq b2, XMM0; movq b2, XMM1;} asm { movq XMM0, b1 ; movq XMM1, b1 ; movq b2, XMM0; movq b2, XMM1;} asm { movq XMM0, b1 ; movq XMM1, b1 ; movq b2, XMM0; movq b2, XMM1;} asm { movq XMM0, b1 ; movq XMM1, b1 ; movq b2, XMM0; movq b2, XMM1;} asm { movq XMM0, b1 ; movq XMM1, b1 ; movq b2, XMM0; movq b2, XMM1;} asm { movq XMM0, b1 ; movq XMM1, b1 ; movq b2, XMM0; movq b2, XMM1;} asm { movq XMM0, b1 ; movq XMM1, b1 ; movq b2, XMM0; movq b2, XMM1;} asm { movq XMM0, b1 ; movq XMM1, b1 ; movq b2, XMM0; movq b2, XMM1;} asm { movq XMM0, b1 ; movq XMM1, b1 ; movq b2, XMM0; movq b2, XMM1;} asm { movq XMM0, b1 ; movq XMM1, b1 ; movq b2, XMM0; movq b2, XMM1;} //*/ /* asm { movdqu XMM0, b1 ; movdqu b2, XMM0; } asm { movdqu XMM0, b1 ; movdqu b2, XMM0; } asm { movdqu XMM0, b1 ; movdqu b2, XMM0; } asm { movdqu XMM0, b1 ; movdqu b2, XMM0; } asm { movdqu XMM0, b1 ; movdqu b2, XMM0; } asm { movdqu XMM0, b1 ; movdqu b2, XMM0; } asm { movdqu XMM0, b1 ; movdqu b2, XMM0; } asm { movdqu XMM0, b1 ; movdqu b2, XMM0; } asm { movdqu XMM0, b1 ; movdqu b2, XMM0; } asm { movdqu XMM0, b1 ; movdqu b2, XMM0; } //* / asm { movdqa XMM0, b1 ; movdqa b2, XMM0; } asm { movdqa XMM0, b1 ; movdqa b2, XMM0; } asm { movdqa XMM0, b1 ; movdqa b2, XMM0; } asm { movdqa XMM0, b1 ; movdqa b2, XMM0; } asm { movdqa XMM0, b1 ; movdqa b2, XMM0; } asm { movdqa XMM0, b1 ; movdqa b2, XMM0; } asm { movdqa XMM0, b1 ; movdqa b2, XMM0; } asm { movdqa XMM0, b1 ; movdqa b2, XMM0; } asm { movdqa XMM0, b1 ; movdqa b2, XMM0; } asm { movdqa XMM0, b1 ; movdqa b2, XMM0; } //*/ // foo.run(b1);//,b2,b3); //*/ } hpc.stop; if( hpc.microseconds < new_time ) new_time = hpc.microseconds; } writefln(a1.a," ",a2.a," ",b1.a," ",b2.a); writefln(a1.b," ",a2.b," ",b1.d," ",b2.d); writefln( loop_time ); writefln( old_time - loop_time ); writefln( new_time - loop_time," ",(new_time - loop_time) * 100.0 /(old_time - loop_time) - 100 ); return 0; }