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]

December 31st, 2019

by in Applied Machine Learning

⟵ Back

Leave a Reply

avatar
  Subscribe  
Notify of