Histogram Speeds in Python

Let’s compare several ways of making Histograms. I’m going to assume you would like to end up with a nice OO histogram interface, so all the 2D methods will fill a Physt histogram. We will be using a 2 x 1,000,000 element array and filling a 2D histogram, or 10,000,000 elements in a 1D histogram. Binnings are regular.

1D 10,000,000 item histogram

ExampleKNLMBPX24
NumPy: histogram704 ms147 ms114 ms
NumPy: bincount432 ms110 ms117 ms
fast-histogram337 ms45.9 ms45.7 ms
Numba312 ms58.8 ms60.7 ms

2D 1,000,000 item histogram

ExampleKNLMBPX24
Physt1.21 s293 ms246 ms
NumPy: histogram2d456 ms114 ms88.3 ms
NumPy: add.at247 ms62.7 ms49.7 ms
NumPy: bincount81.7 ms23.3 ms20.3 ms
fast-histogram53.7 ms10.4 ms7.31 ms
fast-hist threaded 0.5(6) 62.5 ms9.78 ms(6) 15.4 ms
fast-hist threaded (m)62.3 ms4.89 ms3.71 ms
Numba41.8 ms10.2 ms9.73 ms
Numba threaded(6) 49.2 ms4.23 ms(6) 4.12 ms
Cython112 ms12.2 ms11.2 ms
Cython threaded(6) 128 ms5.68 ms(8) 4.89 ms
pybind11 sequential93.9 ms9.20 ms17.8 ms
pybind11 OpenMP atomic4.06 ms6.87 ms1.91 ms
pybind11 C++11 atomic(32) 10.7 ms7.08 ms(48) 2.65 ms
pybind11 C++11 merge(32) 23.0 ms6.03 ms(48) 4.79 ms
pybind11 OpenMP merge8.74 ms5.04 ms1.79 ms
[Read More]
Categories: Python  Tags: programming python 

Announcing CLI11 1.6

CLI11, a powerful library for writing beautiful command line interfaces in C++11, has been updated to 1.6, the largest update ever. CLI11 output is more customizable than ever, and has a better functionality separation under the hood.

CLI11 has had the formatting system completely redesigned, with minor or complete customization of the output possible. Configuration file reading and writing also can be configured; a new example with json instead of ini formatting is included. Validators (finally) have custom help output, as well. Many odd corner cases have been made possible, such as interleaving options.

[Read More]
Categories: cpp  Tags: programming cpp cli cli11 plumbum 

CMake 3.11

CMake 3.11 was just released; this is a particularly exciting release for CMake. I’d like to give a quick and friendly introduction to the new features that might make the largest difference for CMake users.

[Read More]
Categories: cmake  Tags: programming cmake 

Announcing GooFit 2.1

GooFit logo

GooFit 2.1 introduces the full-featured Python bindings to GooFit. These bindings mimic the C++ usage of GooFit, including bindings for all PDFs, and also provide NumPy-centric conversions, live Jupyter notebook printing, pip install, and more. Most of the examples in C++ are provided in Python form, as well.

Several other API changes were made. Observables are now distinguished from Variables and provided as a separate class. Both these classes are now passed around by copy everywhere.1 The three and four body amplitude classes have been refactored and simplified. OpenMP is now supported via homebrew on macOS; GooFit is one of the only packages that currently can build with OpenMP on the default macOS compiler. Eigen is now available, and CLI11 has been updated to version 1.3.

GooFit 2.1 will receive continuing support while development on GooFit 2.2 presses on with a new indexing scheme for PDFs.

[Read More]
Categories: Physics  Tags: programming cpp cmake physics fitting goofit 

Include What You Use

Include-what-you-use is a promising little tool for cleaning up a codebase. It didn’t end up working for the use I had for it, but it still could be useful. Here is a quick guideline on installing it on macOS.

[Read More]
Categories: cpp  Tags: programming macOS cpp 

Comparing CLI11 and Boost PO

CLI11 started years ago as a set of tools built on Boost Program Options (PO), and has since matured into the powerful, easy-to-use stand-alone library it is available today. If you would like to see the original inspiration for CLI11, look at Program.hpp in CLI11 0.1. The rest of the post will focus on a comparison between making a CLI app in the two libraries. I am going to assume that you are preparing fairly basic but non-trivial programs in the following comparison.

TL;DR: CLI11 is more concise, and provides more control with better defaults in many cases, but was inspired by Boost PO.

[Read More]
Categories: cpp  Tags: programming cpp cli11 cli boost