<commit_before>#!/usr/bin/env python
#-*- coding:utf-8 -*-
#
# <License info will go here...>
#
# Written: 5-Mar-2011
#
# Author: <NAME> <<EMAIL>>
# Author: <NAME> <<EMAIL>>
#
# This module is not yet finished. The code in the comments below 
# are what remains to be implemented.
#
# TODO
# 1] Implement File IO test (Test 24)
# 2] Implement smooth test
# 7] Check implementation of fft test
# 8] Check implementation of smooth test
# 9] Need to optimize shifting code for float arrays. Roll is very inefficient!
#
#pylint: disable=C0103,R0912,R0915,W0404
'''Equivalent of time_test3.pro, a performance test, in IDL

    The tests are 
    Test 1 - Empty For Loop
    Test 2 - Empty procedure
    Test 3 - Add 200000 scalar ints
    Test 4 - Scalar arithmetic loop
    Test 5 - Create a 512x512 array filled with bytes(2)
    Test 6 - Mult 512 by 512 byte by constant and store
    Test 7 - Shift 512 by 512 byte and store
    Test 8 - Add constant to 512x512 byte array
    Test 9 - Add two 512 by 512 byte arrays and store
    Test 10 - Mult 512 by 512 floating by constant
    Test 11 - Shift 512 x 512 array
    Test 12 - Add two 512 by 512 floating images
    Test 13 - Generate random numbers
    Test 14 - Invert random matrix
    Test 15 - LU Decomposition of random matrix
    Test 16 - Transpose byte array with FOR loop
    Test 17 - Transpose byte array, row and column ops
    Test 18 - Transpose byte array, TRANSPOSE function
    Test 20 - Log of numbers, vector op
    Test 20 - Forward and inverse FFT
    Test 21 - Smooth 512 by 512 byte array, 5x5 boxcar
     Test 23 - Smooth 512 by 512 floating array, 5x5 boxcar
    Test 24 - Write and read 512 by 512 byte array
'''
import numpy as np
import scipy.fftpack
import scipy.ndimage
import scipy.linalg
import math
import sys
import os
import benchmark

#from collections import deque

def main():
    """Main application"""
    timer = benchmark.BenchmarkTimer()
    
    options = timer.parse_arguments()
    timer.print_header("TIME_TEST3")
    
    run_tests(timer, options.scale_factor)
    
    timer.print_summary()

def run_tests(timer, scale_factor):
    '''Go through each test and print out the results'''
    nofileio = True

    #initialize time
    timer.reset()   
    
    #Test 1 - Empty For loop
    nrep = 2000000 * scale_factor
    for i in xrange(nrep):
        pass
    timer.log("Empty For loop %d times." % nrep)

    #Test 2 - Empty procedure    
    trash = lambda x: 0
 
    nrep = 1000000 * scale_factor
    for i in xrange(nrep):
        trash(i)
    timer.log("Call empty procedure (1 param) %d times." % nrep)
    
    #Test 3 - Add 200000 scalar ints
    nrep = 2000000 * scale_factor<commit_msg>Fixed size mistakes with time_test3<commit_after>#!/usr/bin/env python
#-*- coding:utf-8 -*-
#
# <License info will go here...>
#
# Written: 5-Mar-2011
#
# Author: <NAME> <<EMAIL>>
# Author: <NAME> <<EMAIL>>
#
# This module is not yet finished. The code in the comments below 
# are what remains to be implemented.
#
# TODO
# 1] Implement File IO test (Test 24)
# 2] Implement smooth test
# 7] Check implementation of fft test
# 8] Check implementation of smooth test
# 9] Need to optimize shifting code for float arrays. Roll is very inefficient!
#
#pylint: disable=C0103,R0912,R0915,W0404
'''Equivalent of time_test3.pro, a performance test, in IDL

    The tests are 
    Test 1 - Empty For Loop
    Test 2 - Empty procedure
    Test 3 - Add 200000 scalar ints
    Test 4 - Scalar arithmetic loop
    Test 5 - Create a 512x512 array filled with bytes(2)
    Test 6 - Mult 512 by 512 byte by constant and store
    Test 7 - Shift 512 by 512 byte and store
    Test 8 - Add constant to 512x512 byte array
    Test 9 - Add two 512 by 512 byte arrays and store
    Test 10 - Mult 512 by 512 floating by constant
    Test 11 - Shift 512 x 512 array
    Test 12 - Add two 512 by 512 floating images
    Test 13 - Generate random numbers
    Test 14 - Invert random matrix
    Test 15 - LU Decomposition of random matrix
    Test 16 - Transpose byte array with FOR loop
    Test 17 - Transpose byte array, row and column ops
    Test 18 - Transpose byte array, TRANSPOSE function
    Test 20 - Log of numbers, vector op
    Test 20 - Forward and inverse FFT
    Test 21 - Smooth 512 by 512 byte array, 5x5 boxcar
     Test 23 - Smooth 512 by 512 floating array, 5x5 boxcar
    Test 24 - Write and read 512 by 512 byte array
'''
import numpy as np
import scipy.fftpack
import scipy.ndimage
import scipy.linalg
import math
import sys
import os
import benchmark

#from collections import deque

def main():
    """Main application"""
    timer = benchmark.BenchmarkTimer()
    
    options = timer.parse_arguments()
    timer.print_header("TIME_TEST3")
    
    run_tests(timer, options.scale_factor)
    
    timer.print_summary()

def run_tests(timer, scale_factor):
    '''Go through each test and print out the results'''
    nofileio = True

    #initialize time
    timer.reset()   
    
    #Test 1 - Empty For loop
    nrep = 2000000 * scale_factor
    for i in xrange(nrep):
        pass
    timer.log("Empty For loop %d times." % nrep)

    #Test 2 - Empty procedure    
    trash = lambda x: 0
 
    nrep = 100000 * scale_factor
    for i in xrange(nrep):
        trash(i)
    timer.log("Call empty procedure (1 param) %d times." % nrep)
    
    #Test 3 - Add 200000 scalar ints
    nrep = 200000 * scale_factor
{'fraction_non_alphanumeric': 0.07427937915742794, 'fraction_numerical': 0.06522542498152255, 'mean_word_length': 2.7616400277970814, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1647106', 'n_tokens_mistral': 1966, 'n_tokens_neox': 1619, 'n_words': 731}