Debugging Entity Framework SQL statements

For debugging EF queries, the easiest thing is to cast the query to ObjectQuery and use ToTraceString: var query = myContext.MyTable .Where(r => r.Id == searchId) .Select(r => r); Console.WriteLine(((ObjectQuery)query).ToTraceString()); This will show the underlying SQL for the query, and you can run the queries manually to debug why they are slow. Here is the … Read more

Performance of function slice parameter vs global variable?

Judging from the name of your function, performance can’t be that critical to even consider moving parameters to global variables just to save time/space required to pass them as parameters (IO operations like checking files are much-much slower than calling functions and passing values to them). Slices in Go are just small descriptors, something like … Read more

How can the rep stosb instruction execute faster than the equivalent loop?

In modern CPUs, rep stosb‘s and rep movsb‘s microcoded implementation actually uses stores that are wider than 1B, so it can go much faster than one byte per clock. (Note this only applies to stos and movs, not repe cmpsb or repne scasb. They’re still slow, unfortunately, like at best 2 cycles per byte compared … Read more