Measure time of execution of bubble sort algorithm in different programming languages.
This is set of console applications.
Currently write for Python, C#, C++, JavaScript.
All code written and run under Visual Studio Code (with required compilers and extensions) in Windows 10.
If possible, compiled debug and release (with optimization) versions of executable files.
Run on Acer Swift 3 with Core-i5.
Enter the appropriate folder, optionally compile, and run the code.
Measure bubble sort for integer array with 10000 elements.
Changing elements is done in a function to add the function call lag (optimization makes functions inline).
Language | Compiler | Time of execution (seconds) | Time with optimization (seconds) |
---|---|---|---|
Python | CPython 3.11.4 | 6.1 | - |
C# | .NET 5 | 0.28 | 0.042 |
C++ | g++ 11 | 0.23 | 0.031 |
JavaScript | Node.JS 16 | 0.058 | - |
The task of finding a contiguous subarray with the largest sum.
Use O(n) algorithm. Sum for 10000 elements calculates 10000 times.
Code: Python, C#, C++, JavaScript.
Language | Compiler | Time of execution (seconds) | Time with optimization (seconds) |
---|---|---|---|
Python | CPython 3.11.4 | 16.1 | - |
C# | .NET 5 | 0.35 | 0.14 |
C++ | g++ 11 | 0.36 | 0.09 |
JavaScript | Node.JS 16 | 0.10 | - |