A friend and I wrote an encryption module, and we want to transfer it to several languages so that it is not platform-specific encryption. Originally written in C #, I ported it to C ++ and Java. C # and Java will be encrypted at a speed of about 40 MB / s, but C ++ will only encrypt about 20 MB / s. Why is C ++ running so much slower? Is it because I'm using Visual C ++?
What can I do to speed up my code? Is there another compiler that optimizes C ++ better?
I already tried to optimize the code itself, for example, x >> 3instead of x / 8(integer division) or y & 63instead of y % 64other methods. How can I build a project in a different way so that it is more advanced in C ++?
EDIT:
I have to admit that I have not studied how the compiler optimizes code. I have classes that I will take here at College, which are dedicated to studying compilers and translators.
As for my C ++ code, this is not very difficult. There is NO, there is “basic” mathematics along with what we call a “state jump” in order to produce pseudo-random results. The most complex things we do are bitwise operations, which actually perform encryption and unchecked multiplication during the initial hash phase. There are dynamically distributed 2D arrays that are preserved throughout the entire life cycle of the encryption object (and correctly released in the destructor). There are only 180 lines. Ok, so my micro-optimizations are not needed, but I have to assume that this is not a problem, this is the time. To really expand the point, here is the most difficult line of code in the program:
input [L + offset] ^ = state [state [SIndex ^ 255] and 63];
I do not move arrays or do not work with objects.
, , - # ++ Java, 3 , .
, ++ , # Java ( 1 / ), , ++ , , . , ++, , , , , 99% # ++ 5 , , .
RE-EDIT:
Visual Studio, . ++ 50% , #. , .