12
C++ vs. Python C++ vs. Python By Jahrain Jackson Home Institution: University of Hawaii at Hilo Internship: Subaru Telescope Mentor: Matt Dinkins

C++ vs. Python By Jahrain Jackson Home Institution: University of Hawaii at Hilo Internship: Subaru Telescope Mentor: Matt Dinkins

Embed Size (px)

Citation preview

Page 1: C++ vs. Python By Jahrain Jackson Home Institution: University of Hawaii at Hilo Internship: Subaru Telescope Mentor: Matt Dinkins

C++ vs. PythonC++ vs. PythonBy Jahrain Jackson

Home Institution: University of Hawaii at Hilo

Internship: Subaru Telescope

Mentor: Matt Dinkins

Page 2: C++ vs. Python By Jahrain Jackson Home Institution: University of Hawaii at Hilo Internship: Subaru Telescope Mentor: Matt Dinkins

22

The ProblemThe Problem

The Subaru Software Development team (SSD) The Subaru Software Development team (SSD) is migrating their instrument control software is migrating their instrument control software from C/C++ to Python.from C/C++ to Python.

Lack of performance comparisons directly Lack of performance comparisons directly between the two languages.between the two languages.

Information on performance impacts from Information on performance impacts from migrated code is needed.migrated code is needed.

Page 3: C++ vs. Python By Jahrain Jackson Home Institution: University of Hawaii at Hilo Internship: Subaru Telescope Mentor: Matt Dinkins

33

My ProjectMy Project

Write performance benchmarking software Write performance benchmarking software in both C/C++ and Python.in both C/C++ and Python.Execute software on Subaru’s Real Time Execute software on Subaru’s Real Time System (AO188RTS) System (AO188RTS) Construct a Wiki page on Subaru’s Wiki to Construct a Wiki page on Subaru’s Wiki to present an analysis on the results.present an analysis on the results.

Page 4: C++ vs. Python By Jahrain Jackson Home Institution: University of Hawaii at Hilo Internship: Subaru Telescope Mentor: Matt Dinkins

44

Why Python?Why Python?C++ Python

Complex syntax

Difficult to read

Minimal Syntax

Easier to read and debug

Faster development time

Increases productivity

Page 5: C++ vs. Python By Jahrain Jackson Home Institution: University of Hawaii at Hilo Internship: Subaru Telescope Mentor: Matt Dinkins

55

Compiled vs. Interpreted

C++ is a compiled language.

Code is translated from a human readable text form into an executable form that a machine can read.

Compiled code is hardware specific.

Python is an interpreted language.

Code is translated into a machine readable form during run time by an interpreter application.

Interpreted code run on any platform with the interpreter installed.

Page 6: C++ vs. Python By Jahrain Jackson Home Institution: University of Hawaii at Hilo Internship: Subaru Telescope Mentor: Matt Dinkins

66

Benchmarking SuiteBenchmarking Suite

Output GUI

Page 7: C++ vs. Python By Jahrain Jackson Home Institution: University of Hawaii at Hilo Internship: Subaru Telescope Mentor: Matt Dinkins

77

Testing EnvironmentTesting Environment

AO188RTS - Subaru’s Real Time AO188RTS - Subaru’s Real Time System for controlling the adaptive System for controlling the adaptive optics equipmentoptics equipment

4x Intel Xeon 2GHz Processors4x Intel Xeon 2GHz Processors

RedHawk 4 LinuxRedHawk 4 Linux

Python v2.3, GCC v3.4.6 Python v2.3, GCC v3.4.6 (outdated)(outdated)

Real Time System – A specialized Real Time System – A specialized computer set up for software to computer set up for software to respond immediately with minimal respond immediately with minimal interference from other processes.interference from other processes.

Page 8: C++ vs. Python By Jahrain Jackson Home Institution: University of Hawaii at Hilo Internship: Subaru Telescope Mentor: Matt Dinkins

88

Results - The GoodResults - The Good

Searching Sorting

C++ Python C++ Python

(Shorter is better)

Run

time

(ms)

Page 9: C++ vs. Python By Jahrain Jackson Home Institution: University of Hawaii at Hilo Internship: Subaru Telescope Mentor: Matt Dinkins

99

Results – The BadResults – The Bad

C++ Python Jitter

Vector Normalization

Page 10: C++ vs. Python By Jahrain Jackson Home Institution: University of Hawaii at Hilo Internship: Subaru Telescope Mentor: Matt Dinkins

1010

Results – The UglyResults – The Ugly

C++ Python Jitter

Matrix Inversion

Page 11: C++ vs. Python By Jahrain Jackson Home Institution: University of Hawaii at Hilo Internship: Subaru Telescope Mentor: Matt Dinkins

1111

ConclusionsConclusions

Python ran an average of 4x slower than C++ in Python ran an average of 4x slower than C++ in averaging all test results.averaging all test results.Runtime jitter is more important for real-time applications Runtime jitter is more important for real-time applications than average execution times.than average execution times.Mathematical, memory intensive, or complex algorithms Mathematical, memory intensive, or complex algorithms suffer the biggest performance impacts in Python.suffer the biggest performance impacts in Python.Utilizing Pythons built in methods or external modules Utilizing Pythons built in methods or external modules can produce near or better than C++ performance.can produce near or better than C++ performance.

Page 12: C++ vs. Python By Jahrain Jackson Home Institution: University of Hawaii at Hilo Internship: Subaru Telescope Mentor: Matt Dinkins

1212

AcknowledgementsAcknowledgements

Matt Dinkins – Project director and Python and Linux guru, helped Matt Dinkins – Project director and Python and Linux guru, helped me learn allot about Python and operating Linux systems.me learn allot about Python and operating Linux systems.

Subaru Telescope – For the internship opportunity and facilitating Subaru Telescope – For the internship opportunity and facilitating our research with the usage of their computers and equipment.our research with the usage of their computers and equipment.

Akamai Internship Program – Hosting and organizing my internship Akamai Internship Program – Hosting and organizing my internship at Subaru Telescope.at Subaru Telescope.

The Akamai Internship Program is funded by the Center for Adaptive Optics through its National Science Foundation Science and Technology Center grant (#AST-987683).