Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Improve Tektronix_AWG5014 performance #656

Merged
merged 3 commits into from
Jun 23, 2017

Conversation

antsr
Copy link
Contributor

@antsr antsr commented Jun 22, 2017

pack_waveform in Tektronix_AWG5014 uses Python native functions like min, max and count,
which are slow compared to the numpy alternatives. This update replaces the Python function calls
with numpy alternatives considerably improving the speed of programming the Tektronix AWG5014
while leaving the functionality the same.

As an example, on my machine:

> data = np.random.choice([0, 1], 10000)

> %timeit list(data).count(0) + list(data).count(1) == len(data)
100 loops, best of 3: 5.23 ms per loop

> %timeit np.all(np.in1d(data, np.array([0, 1])))
The slowest run took 9.76 times longer than the fastest. This could mean that an intermediate result is being cached.
10000 loops, best of 3: 70.3 µs per loop

Changes proposed in this pull request:

  • Change native Python functions in Tektronix_AWG5014.pack_waveform to numpy versions.

@giulioungaretti

antsr added 2 commits June 22, 2017 14:02
`pack_waveform` in `Tektronix_AWG5014` uses Python native functions like `min`, `max` and `count`,
which are slow compared to the numpy alternatives. This update replaces the Python function calls
with numpy alternatives considerably improving the speed of programming the Tektronix AWG.
Marker 1 was checked twice instead of also checking marker 2 for values other than 0 or 1 in
Tektronix_AWG5014.pack_waveform
Copy link
Contributor

@WilliamHPNielsen WilliamHPNielsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is indeed a change that is only an improvement. Good job.

@WilliamHPNielsen WilliamHPNielsen merged commit 0fed812 into microsoft:master Jun 23, 2017
giulioungaretti pushed a commit that referenced this pull request Jun 23, 2017
Author: Ants Remm <[email protected]>

    perf: Improve Tektronix_AWG5014 performance (#656)
@antsr antsr deleted the perf/awg5014 branch June 23, 2017 12:09
Dominik-Vogel pushed a commit to Dominik-Vogel/Qcodes that referenced this pull request Aug 9, 2017
* perf: improve Tektronix_AWG5014 performance

`pack_waveform` in `Tektronix_AWG5014` uses Python native functions like `min`, `max` and `count`,
which are slow compared to the numpy alternatives. This update replaces the Python function calls
with numpy alternatives considerably improving the speed of programming the Tektronix AWG.

* fix: marker 1 checked instead of marker 2

Marker 1 was checked twice instead of also checking marker 2 for values other than 0 or 1 in
Tektronix_AWG5014.pack_waveform
peendebak pushed a commit to VandersypenQutech/Qcodes that referenced this pull request Aug 11, 2017
* perf: improve Tektronix_AWG5014 performance

`pack_waveform` in `Tektronix_AWG5014` uses Python native functions like `min`, `max` and `count`,
which are slow compared to the numpy alternatives. This update replaces the Python function calls
with numpy alternatives considerably improving the speed of programming the Tektronix AWG.

* fix: marker 1 checked instead of marker 2

Marker 1 was checked twice instead of also checking marker 2 for values other than 0 or 1 in
Tektronix_AWG5014.pack_waveform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants