Skip to content

Commit

Permalink
Merge branch 'master' into bench-Add
Browse files Browse the repository at this point in the history
  • Loading branch information
bjodah committed Nov 12, 2024
2 parents 834d10f + 7fdab96 commit 60c4a88
Show file tree
Hide file tree
Showing 40 changed files with 9,142 additions and 184 deletions.
10 changes: 0 additions & 10 deletions .asv-machine.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json linguist-language=jsonc
30 changes: 30 additions & 0 deletions .github/workflows/run-benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run benchmarks

on: [push, pull_request]

jobs:

benchmarks:

runs-on: ubuntu-20.04

steps:

- name: Checkout SymPy Benchmarks
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install virtualenv asv packaging
- name: Configure benchmarks
run: asv machine --yes --config asv.conf.actions.json

- name: Run benchmarks
run: asv run --config asv.conf.actions.json
11 changes: 4 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
*.pyc
*/*.pyc
*/*/*.pyc
__pycache__/
*/__pycache__/
*/*/__pycache__/
.cache/
**.pyc
**/__pycache__/
.cache*/
env/
results/
sympy/
html/
.python-version
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

163 changes: 120 additions & 43 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,90 +1,167 @@
SymPy's benchmark suite
=======================

.. image:: http://img.shields.io/badge/benchmarked%20by-asv-green.svg?style=flat
:target: http://hera.physchem.kth.se/~sympy_asv
:alt: airspeedvelocity

.. image:: https://travis-ci.org/sympy/sympy_benchmarks.png?branch=master
:target: https://travis-ci.org/sympy/sympy_benchmarks
SymPy's Benchmark Suite
-----------------------

|airspeedvelocity| |image1|

This is the benchmark suite for `SymPy <http://github.com/sympy/sympy>`__.
This is the benchmark suite for
`SymPy <http://github.com/sympy/sympy>`__.

These benchmarks track the performance of various features in SymPy
*over time*.

Results are currently hosted in an ad hoc manner, you may find some results `here
<http://hera.physchem.kth.se/~sympy_asv>`__ and `here <http://www.moorepants.info/misc/sympy-asv/>`__.
Results are currently hosted in an ad hoc manner, you may find some
results `here <http://hera.physchem.kth.se/~sympy_asv>`__ and
`here <http://www.moorepants.info/misc/sympy-asv/>`__.

The benchmarks are run using `airspeed velocity
<https://asv.readthedocs.io/>`__.

When adding benchmarks, mirror the SymPy directory tree for the feature you are
adding. If your benchmark is not for a specific feature such that creating
subdirectories for your benchmark is not reasonable, put your benchmark in the
top level benchmarking directory.
The benchmarks are run using `airspeed
velocity <https://asv.readthedocs.io/>`__.

When adding benchmarks, mirror the SymPy directory tree for the feature
you are adding. If your benchmark is not for a specific feature such
that creating subdirectories for your benchmark is not reasonable, put
your benchmark in the top level benchmarking directory.

Quickstart
----------
~~~~~~~~~~

--------------

Installation
^^^^^^^^^^^^

Firstly, you need to install ``asv``
These benchmarks are run using *airspeed velocity* so, you need to have
``asv`` installed,

``pip install asv``
::

$ pip install asv

or in conda environment, use

``conda install -c conda-forge asv``
::

$ conda install -c conda-forge asv

If you're not using conda, you may also need to install ``virtualenv``.
If you're not using conda, you also needs to have ``virtualenv``
installed.

``pip install virtualenv``
::

$ pip install virtualenv

Running the benchmarks
^^^^^^^^^^^^^^^^^^^^^^

To quickly try out the benchmarks (e.g. while developing a new benchmark you can
run it against a single commit on sympy master::
To quickly try out the benchmarks (e.g. while developing a new benchmark
you can run it against a single commit on sympy master:

::

$ asv --quick "HEAD^!"

$ ./run_benchmarks.sh --quick "HEAD^!"
If you work with ``conda`` , you should change the
``"environment_type"`` entry in ``asv.conf.json`` from ``"virtualenv"``
to ``"conda"``. Or you can use,

You may also use ``asv run --bench <Name>`` to selectively run a specific
benchmark based on the function or class name in ``benchmarks/`` or
``slow_benchmarks/`` folder. It also supports regular expressions.
::

$ asv --config asv.conf.conda.json --quick "HEAD^!"

You can also run a specific benchmark based on the function or class
name in ``benchmarks/`` or ``slow_benchmarks/`` folder.

::

$ asv run --bench <Name>

It also supports regular expressions.

The benchmark results will be stored in your ``results/`` folder.

See `asv documentation <https://asv.readthedocs.io/en/stable/commands.html#asv-run>`__
See `asv
documentation <https://asv.readthedocs.io/en/stable/commands.html#asv-run>`__
for additional information.

Running the benchmarks locally
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Currently, this suite is pointing to SymPy's base repository for
benchmarking. In order to run these benchmarks on your local checkout,
you will need to change the value of the ``"repo"`` entry in
``asv.conf.json`` and ``asv.conf.conda.json`` files, from the base
repository's url to your local directory where your fork is stored.

This value should be a path, relative to the location of
``asv.conf.json`` config file.

E.g., if your ``sympy`` fork and ``sympy_benchmarks`` are stored in the
same folder then you should change the value of *"repo"* as

::

"repo" : "../sympy/",

You can also run benchmarks on your remote fork by using the remote
fork's url address instead.

Comparing benchmarks between two branches
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You can also compare the benchmarks between two branches/commits. For
that you need to create benchmarks for each one first. Do this for both,

::

$ asv run -s 1 COMMIT

Then you need to run ``asv compare`` on them.

::

$ asv compare COMMIT1 COMMIT2

here ``commit`` can be replaced with branch names or commit hashes.

If you are comparing the benchmarks of a branch against master, use the
commit hash of the master that branch is based on. Otherwise, new
unrelated commits in the master can affect the results. Alternately you
can also merge master into the branch first to make sure it is
up-to-date.

Running benchmarks for a selection of commits
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Generally we're not interested in benchmarking every single commit to the sympy repo.
For example, we might be interested in some tagged releases::

$ for release in 1.0 1.1 1.2 1.3 1.4; do asv run "sympy-$release^!"; done
Generally we're not interested in benchmarking every single commit to
the sympy repo. For example, we might be interested in some tagged
releases:

::

or all the merge commits to the master branch since some tag::
$ for release in 1.0 1.1 1.2 1.3 1.4; do asv run "sympy-$release^!"; done

$ git rev-list --merges sympy-1.0..HEAD
or all the merge commits to the master branch since some tag:

::

$ git rev-list --merges sympy-1.0..HEAD

Creating and viewing the HTML report
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Use ``asv publish`` command to create an HTML report.

It will generate an HTML report in your ``html/`` folder. However, you may
not be able to use the HTML files directly.
It will generate an HTML report in your ``html/`` folder. However, you
may not be able to use the HTML files directly.

After generating the HTML files, you have to use ``asv preview`` to create
a server locally. And navigate to ``http://127.0.0.1:8080/`` to view the
report.
After generating the HTML files, you have to use ``asv preview`` to
create a server locally. And navigate to ``http://127.0.0.1:8080/`` to
view the report.

See `asv documentation <https://asv.readthedocs.io/en/stable/commands.html#asv-publish>`__
See `asv
documentation <https://asv.readthedocs.io/en/stable/commands.html#asv-publish>`__
for additional information.

.. |airspeedvelocity| image:: http://img.shields.io/badge/benchmarked%20by-asv-green.svg?style=flat
:target: http://hera.physchem.kth.se/~sympy_asv
.. |image1| image:: https://travis-ci.org/sympy/sympy_benchmarks.png?branch=master
:target: http://hera.physchem.kth.se/~sympy_asv
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-midnight
88 changes: 88 additions & 0 deletions asv.conf.actions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
// This is the configuration file used for running the benchmarks from
// sympy_benchmarks in GitHub Actions. The commands that are run can be
// seen in run-benchmarks.yml.

// The version of the config file format. Do not change, unless
// you know what you are doing.
"version": 1,

// The name of the project being benchmarked
"project": "sympy",

// The project's homepage
"project_url": "http://sympy.org/",

// The URL or local path of the source code repository for the
// project being benchmarked
"repo": "https://github.com/sympy/sympy.git",

// The command to run to build the project.
// https://github.com/sympy/sympy/issues/26239
"build_command": [
"python -m pip install build",
"python -m build --wheel -o {build_cache_dir} {build_dir}"
],

// List of branches to benchmark. If not provided, defaults to "master"
// (for git) or "tip" (for mercurial).

// This list needs to be updated after each release of sympy. The branch to
// be checked should always be the previous release.
"branches": ["1.12", "master", "HEAD"], // for git
// "branches": ["tip"], // for mercurial

// The DVCS being used. If not set, it will be automatically
// determined from "repo" by looking at the protocol in the URL
// (if remote), or by looking for special directories, such as
// ".git" (if local).
// "dvcs": "git",

// The tool to use to create environments. May be "conda",
// "virtualenv" or other value depending on the plugins in use.
// If missing or the empty string, the tool will be automatically
// determined by looking for tools on the PATH environment
// variable.
"environment_type": "virtualenv",

// the base URL to show a commit for the project.
"show_commit_url": "http://github.com/sympy/sympy/commit/",

// The Pythons you'd like to test against. If not provided, defaults
// to the current version of Python used to run `asv`.
"pythons": ["3.10"],

// The matrix of dependencies to test. Each key is the name of a
// package (in PyPI) and the values are version numbers. An empty
// list indicates to just test against the default (latest)
// version.
"matrix": {
"pip+fastcache": [],
"pip+mpmath": [],
"pip+numpy": []
},

// The directory (relative to the current directory) that benchmarks are
// stored in. If not provided, defaults to "benchmarks"
// "benchmark_dir": "benchmarks",

// The directory (relative to the current directory) to cache the Python
// environments in. If not provided, defaults to "env"
// "env_dir": "env",

// The directory (relative to the current directory) that raw benchmark
// results are stored in. If not provided, defaults to "results".
// "results_dir": "results"

// The directory (relative to the current directory) that the html tree
// should be written to. If not provided, defaults to "html".
// "html_dir": "html",

// The number of characters to retain in the commit hashes.
// "hash_length": 8,

// `asv` will cache wheels of the recent builds in each
// environment, making them faster to install next time. This is
// number of builds to keep, per environment.
// "wheel_cache_size": 0
}
9 changes: 8 additions & 1 deletion asv.conf.conda.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
// project being benchmarked
"repo": "https://github.com/sympy/sympy.git",

// The command to run to build the project.
// https://github.com/sympy/sympy/issues/26239
"build_command": [
"python -m pip install build",
"python -m build --wheel -o {build_cache_dir} {build_dir}"
],

// List of branches to benchmark. If not provided, defaults to "master"
// (for git) or "tip" (for mercurial).
// "branches": ["master"], // for git
Expand All @@ -36,7 +43,7 @@

// The Pythons you'd like to test against. If not provided, defaults
// to the current version of Python used to run `asv`.
"pythons": ["2.7", "3.6"],
// "pythons": ["2.7", "3.6"],

// The matrix of dependencies to test. Each key is the name of a
// package (in PyPI) and the values are version numbers. An empty
Expand Down
Loading

0 comments on commit 60c4a88

Please sign in to comment.