E00: Software Drag Racing: C++ vs C# vs Python - Which Will Win?
Video Statistics and Information
Channel: Dave's Garage
Views: 355,358
Rating: undefined out of 5
Keywords: python programming, c++ programming, programming language, best programming language, top programming languages, best programming language to learn 2020, programming languages 2021, programming language c, fastest language, compare python and, compare python and c++
Id: D3h62rgewZM
Channel Id: undefined
Length: 23min 30sec (1410 seconds)
Published: Thu Mar 25 2021
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
Dont ask python experts for ways to make the code faster. They will optimize it until it is one line of completely unreadable symbols
Looks like with few changes to the C# and it becomes much closer to the C++ in performance? https://github.com/davepl/Primes/pull/6
BTW, I think it's a safe bet that the interpreted language is at a deficit, but by how much, etc? And is C++ twice as fast as C#, or 5x, or 10x? That's what it's about :-)
Neat. I'd be interested in seeing the M1 results too!
Would you do a similar type of analysis for something higher level like serving web requests? I know there's a lot more variables at play like web server and frameworks, etc, but I'd still love to hear your perspective.
For the Python version, what happens if you remove the the even-argument
if
statements inGetBit
andClearBit
and inline those two functions? (I suppose the same question applies to the other versions, but perhaps the compilers are doing a better job at avoiding function call and conditional branching overhead in those languages.)/u/daveplreddit/: why do your dictionaries have a value of 1 (instead of 4) for the β10β entry? It makes your program report βValid: Falseβ on that case.
Ported c++ one to D (made some changes to make it as fast as c++).
$ g++ primecpp.cpp -O3 -m64 -oprimecpp -std=c++20 && ./primecpp
$ ldc2 -m64 -O3 primed && ./primed
gcc from Cygwin.
I did have to add a couple includes to the c++ one due to missing symbols (cstring + cmath).
Source:
```d import std.datetime.stopwatch; import std.stdio : write, writef, writeln, writefln; import std.math : sqrt; import core.time : seconds; import core.stdc.stdlib : malloc, free;
bool haveMyDictIndex(size_t index) { switch(index) { case 10: case 100: case 1000: case 10000: case 100000: case 1000000: case 10000000: case 100000000: return true;
}
size_t myDictValue(size_t index) { switch(index) { case 10: return 1; case 100: return 25; case 1000: return 168; case 10000: return 1229; case 100000: return 9592; case 1000000: return 78498; case 10000000: return 664579; case 100000000: return 5761455;
}
struct prime_sieve { private: size_t sieveSize; ubyte[] rawBits;
public: this(size_t n) { sieveSize = n; immutable size_t length = n / 8 + 1;
}
void main() { size_t passes;
} ```
Dave put out a new video and casually mentioned that one of the newer languages is being all the rest. Does anyone know where one can find the results from all the languages?
There's this repo but I haven't had a chance to run it myself. https://github.com/PlummersSoftwareLLC/Primes