Skip to content

Comparing the performance of different versions of Python and C++.

License

Notifications You must be signed in to change notification settings

cuicaihao/python-speedy

 
 

Repository files navigation

Python Performance Test From 3.5 To 3.11

中文

Use Docker to test the performance of different versions of Python and compare it to C++ on the same task.

WARNING

The Optimized C++ version (-O3) (0.336514) acticutally is way more faster than the C++ -O (11.1504 seconds ) in the following example. Thus C++ is still the best choice for this task and it is ~110x times faster than Python 3.11.

The following figure shows the performance of different versions of Python and C++ (Non-Optimized) on the same task. The optimized C++ version is not included in the following figure.

Dependencies

  • Python environment
  • Docker

Benchmark Test Task (K-mers)

Background

DNA K-mers In bioinformatics, k-mers are substrings of length k contained within a biological sequence. Primarily used within the context of computational genomics and sequence analysis.

Genome assembly algorithm DNA K-mers. The idea behind this algorithm is simple, DNA is a long string of sequences called nucleotides.

In DNA, there are 4 nucleotides represented by the letters A, C, G and T. Humans (or more accurately Homo sapiens) have 3 billion nucleotide pairs. For example, a small portion of human DNA might be:

ACTAGGGATCATGAAGATAATGTTGGTGTTTGTATGGTTTTCAGACAATT 

Task Description

In this example, if one wanted to select any 4 consecutive nucleotides (i.e. letters) from this string, it would be a k-mer of length 4 ( We call it 4-mer).

Here are some examples of 4-mers derived from the examples.

ACTA, CTAG, TAGG, AGGG, GGGA

For this repo, let's generate all possible 13-mers. Mathematically, this is a permutation problem. Therefore, we have $4^{13} (=67108864)$ possible 13-mers.

I use a simple algorithm to generate results in C++ and Python.

Let's see how different Python versions compare to C++.

Quick Start

Test the performance of different versions of Python and compare it to C++ on the same task.

python run_main_test.py

Run the C++ version of Task

IF you want to run the C++ version of Task, you need to install the g++ compiler.

Create the Figures

Original Post:

About

Comparing the performance of different versions of Python and C++.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 98.2%
  • Python 1.4%
  • C 0.4%