Talk to an expert

December 31st, 2019

Slow Performance Test Notebook

by in Applied Machine Learning

Slow Performance Test Notebook

Notebook for the slow performance post (https://www.translucentcomputing.com/2019/12/performance-in-jupyter-python/). The slow method has been moved into another file. The mprun magic command requires for the profiled code to be in another file.

slow_example.py

import math
import random

# Really slow generation of synthetic data
def reallySlowGenerateTimeSeriesData(seconds,samples_per_second):
    """Generate synthetic data"""
    
    time = []
    signal = []   
    
    # generate signal
    sample_time = 0
    for s in range(seconds):        
        for sps in range(samples_per_second):
            sample_time += 1/samples_per_second
            noise = random.random()
            scaled_noise = -1 + (noise * 2)
            sample = math.sin(2*math.pi*10*sample_time) + scaled_noise
            time.append(sample_time)
            signal.append(sample)
    
    # return time and signal
    return [time,signal]
0 0 votes
Article Rating

December 31st, 2019

by in Applied Machine Learning

⟵ Back

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

0
Would love your thoughts, please comment.x
()
x