Benchmarking C++, x86 Assembly and Python

preview_player
Показать описание
Comparison of three programming languages. Python, C++ and Assembly. I am running three programs, each print 20000 numbers to the screen. The point of the video is to see which programming language is the fastest at doing so. I am conducting the experiments on a Windows 7 Home Premium Desktop computer with an i7-930 Intel CPU at 2.80 GHz with an x58 motherboard and 12GB of DDR3 1600 ram.

The song: Illamerica - Wolfgang Gartner.

Regarding copyright for the song...
17 U.S.C. § 107
Notwithstanding the provisions of sections 17 U.S.C. § 106 and 17 U.S.C. § 106A, the fair use of a copyrighted work, including such use by reproduction in copies or phonorecords or by any other means specified by that section, for purposes such as criticism, comment, news reporting, teaching (including multiple copies for classroom use), scholarship, or research, is not an infringement of copyright. In determining whether the use made of a work in any particular case is a fair use the factors to be considered shall include:
the purpose and character of the use, including whether such use is of a commercial nature or is for nonprofit educational purposes;
the nature of the copyrighted work;
the amount and substantiality of the portion used in relation to the copyrighted work as a whole; and
the effect of the use upon the potential market for or value of the copyrighted work.
The fact that a work is unpublished shall not itself bar a finding of fair use if such finding is made upon consideration of all the above factors.

Should you still insist that I am infringing upon copyright rights, feel free to check out the Wikipedia page on "Fair Use".
Рекомендации по теме
Комментарии
Автор

When you print to the console it dramatically changes the speed your programs run at. You need to just run in the background and keep track of how long it takes. We can't even tell without some sort of benchmark number

jcdentonunatco
Автор

This is why I love assembly. Coding in assembly is easy as you know exactly what's going on in your code. You can write small, clean, efficient and reliable code :)

Everyone saying ASM is difficult to learn, it's not. Please don't discourage people from using such a powerful programming tool.
I'd suggest if you want to start coding in ASM, learn while you practise. Write something! It worked for me :)

pushd 0
call dword ptr ExitProcess

By y'all!

caraames
Автор

C/C++ is compiled to assembly. Modern C/C++ compilers are very good at producing assembly, it takes someone who really knows what he/she is doing in order to produce hand written assembly code that is faster than optimized compiler generated code

stormelc
Автор

More accurate would be to write program, that does not print anything - only calculates internally. Running one at the time with highest priority would be more legit too. Any OS calls in assembly code slows it down.

Atad
Автор

It's wasn't installed on neither of 3 of my linux systems.

EddieKMusic
Автор

I like that you are trying to compare the languages, but like terrasque mentioned, you didn't benchmark the speed of operations. Also, you need to actually program in some sort of timing mechanism. If we are talking about speed in Assembly, I/O operations wouldn't really be a part of the test, since the power of assembly would be whats done exclusively in the processor.

WhosFrosty
Автор

I have a question about that. I learning assembly right now. I spent more than 2 months only. But for embedded systems. And in this area people usually use C not assembly. I just watch your video and notice that it's size almost 100 times smaller than C file. Also Assembly almost 2 times faster than C.

I dont understand why people dont use Assembly. Of course I'm learning now but I dont think that its is complicated. Accually I think its the most simplyfy language If you know what are you doing exactly.

Maybe that instruction set will be depent on microprocessors or microcontroller but... Lets just say if i'm creating a operating system for macos, I'd prefer assembly not C.

Because as I said, its 100 time smaller than C and almost 2 times faster.

Miracle__
Автор

Hey mate, what you're "benchmarking" is really the windows terminal :) And the window with focus has a slightly higher priority. Run them one by one, write to file (or /dev/null), and do timing on them that way. But even then, you're not really benchmarking the language :)

Try writing a mandelbrot fractal calculator, or calculate the first 2^16 prime numbers. Or even a hashing system, like SHA512 or bcrypt. Then compare speed :)

terrasque
Автор

It would be very very rare one can write better assembly code than C++ optimized compiler.

vector
Автор

Nice test I don't know why there is so much dislike, that a good test, and you explain at the end why assembly is more faster than c++ and python.

waliddu
Автор

How about if I write a code in binary? Will it be faster? Even if I knew the code, can we directly feed binary to a computer?

therealb
Автор

a start time stamp & end time stamp ?

shupesmerga
Автор

Why start them all at once?
time of launch time of return.
for each one of.
compare that?

nickdrozd
Автор

How does some one knows how to do such tests and yet fail to edit a simple video that even 10 yrl old minecraft youtubers do? LLOLL

sgm
Автор

this doesnt make sense. c++ is considered the fastest surface level programming language, being after assembler, even agreed to be so by this very video creator, yet python beat c++ and came in 2nd to assembler (which should obviously be first).

does this have to do with what is installed with python and be it just reading numbers? like if you were to make a big program, would that change the outcome, or was the c++ program inoptimal or something?...

PoKeKidMPK
Автор

The code run slow is not about to convert it to binary . Maybe high level language need to use more binary because you need about 7 lines of code to print hello world in assembly only 1 line of code in python we don't know how many lines of ASM code in background

myothuzaw
Автор

Instead of bad music and subtitles on screen, just talk and get rid of the music

desertshadow
Автор

Python installed by default in most unix-like OSs :p

raoul
Автор

It would be nice to see benchmarks on different hardware systems since it is not just the clockspeed and environment that influences the speed. On windows pc's, I heard vague reference that there are some software and now hardware restrictions which make user run low level assembly slower than it could be and prevent access to hardware compents through propreitary "trusted" drivers? I thought windows forced non-proprietary programs to work on slower hardware spaces and force a lot of spyware hooks or virtualization, which would slow them down a lot, while reserving the faster hardware components for their proprietary junk...essentially hardware non-neutrality. Isn't this true, and if so how can you avoid it to make user programs work optimally...linux systems or special open-source hardware? People who need to develop fast software for cutting edge applications need to know what is the real skinny for assembler applications. If anyone knows, please let me know. #NoWalledGardens.

zackbarkley
Автор

ASM is indeed fast but it is extremely hard to learn so developers use other languages such as c++.

steven
welcome to shbcf.ru