Comparative analysis of code execution time by C and Python based on selected algorithms

Paweł Rysak

pavelrysak@gmail.com
Lublin University of Technology (Poland)

Abstract

The article deals with a comparative analysis of the speed of code execution written in the C language and Python. In order to determine whether a scripting language can match the performance of a compiled language, a comparison of the languages was made using the following algorithms: the algorithm for solving the Hanoi tower problem, the Huffman encoding algorithm and the algorithm for converting numbers into text. Each of the listed algorithms was implemented in both languages. Then the execution time of the programs was measured and the results were obtained, which prove that the C language achieves better performance in most cases.


Keywords:

performance; algorithms; C; Python

Analysis of C++ and Python in Terms of Memory and Time, Preprints (2020), https://doi.org/10.20944/preprints202012.0516.v1.
DOI: https://doi.org/10.20944/preprints202012.0516.v1   Google Scholar

L. Prechelt, An empirical comparison of seven programming languages, Computer 33 (10) (2000) 23-29, https://doi.org/10.1109/2.876288.
DOI: https://doi.org/10.1109/2.876288   Google Scholar

H. Zhang, J. Nie, Program Performance Test based on Different Computing Environment, 2016 IEEE International Conference of Online Analysis and Computing Science (ICOACS) (2016) 174-177.
DOI: https://doi.org/10.1109/ICOACS.2016.7563073   Google Scholar

J. -J. Merelo-Guervós et al., A comparison of implementations of basic evolutionary algorithm operations in different languages, 2016 IEEE Congress on Evolutionary Computation (CEC) (2016) 1602-1609.
DOI: https://doi.org/10.1109/CEC.2016.7743980   Google Scholar

V. M. Ionescu, F. M. Enescu, Investigating the performance of MicroPython and C on ESP32 and STM32 microcontrollers, 2020 IEEE 26th International Symposium for Design and Technology in Electronic Packaging (SIITME) (2020) 234-237.
DOI: https://doi.org/10.1109/SIITME50350.2020.9292199   Google Scholar

Sposób pomiaru czasu wykonania programu w języku C, https://levelup.gitconnected.com/8-ways-to-measure-execution-time-in-c-c-48634458d0f9 , [01.02.2022].
  Google Scholar

Opis wyrażenia makro CLOCKS_PER_SEC, https://www.educative.io/answers/what-is-clockspersec-in-c , [25.09.2022].
  Google Scholar

Sposób pomiaru czasu wykonania programu w języku Python, https://pynative.com/python-get-execution-time-of-program/ , [01.02.2022].
  Google Scholar

Opis problemu dotyczącego algorytmu rozwiązującego problem wieży Hanoi, https://pl.wikipedia.org/wiki/Wie%C5%BCe_Hanoi , [01.02.2022].
  Google Scholar

Kod algorytmu rozwiązującego problem wieży Hanoi w języku C oraz Python, https://www.geeksforgeeks.org/c-program-for-tower-of-hanoi/ , [03.04.2022].
  Google Scholar

Opis przebiegu algorytmu kodowania Huffmana, https://binarnie.pl/kodowanie-huffmana/ , [01.02.2022].
  Google Scholar

Kod algorytmu kodowania Huffmana w języku C oraz Python, https://www.programiz.com/dsa/huffman-coding , [03.04.2022].
  Google Scholar

Kod algorytmu kodowania Huffmana w języku C oraz Python, https://www.techiedelight.com/huffman-coding/ , [03.04.2022].
  Google Scholar

Download


Published
2023-03-30

Cited by

Rysak, P. (2023). Comparative analysis of code execution time by C and Python based on selected algorithms. Journal of Computer Sciences Institute, 26, 93–99. https://doi.org/10.35784/jcsi.3109

Authors

Paweł Rysak 
pavelrysak@gmail.com
Lublin University of Technology Poland

Statistics

Abstract views: 302
PDF downloads: 259