Is ‘switch’ faster than ‘if’?

Is a switch statement actually faster than an if statement? I ran the code below on Visual Studio 2010’s x64 C++ compiler with the /Ox flag: #include <stdlib.h> #include <stdio.h> #include <time.h> #define MAX_COUNT (1 << 29) size_t counter = 0; size_t testSwitch() { clock_t start = clock(); size_t i; for (i = 0; i … Read more

Why does Java switch on contiguous ints appear to run faster with added cases?

I am working on some Java code which needs to be highly optimized as it will run in hot functions that are invoked at many points in my main program logic. Part of this code involves multiplying double variables by 10 raised to arbitrary non-negative int exponents. One fast way (edit: but not the fastest … Read more

Is it possible to “decompile” a Windows .exe? Or at least view the Assembly?

A friend of mine downloaded some malware from Facebook, and I’m curious to see what it does without infecting myself. I know that you can’t really decompile an .exe, but can I at least view it in Assembly or attach a debugger? Edit to say it is not a .NET executable, no CLI header. 16 … Read more