from __future__ import print_function
import time
import random
from pyRMSD.condensedMatrix import CondensedMatrix
import pyRMSD.benchmark.alias.condensedMatrix as PythonCondensedMatrix
import pyRMSD.benchmark.alias.CythonCondensedMatrix as CythonCondensedMatrixes  #@UnresolvedImport

if __name__ == '__main__':

    print("Creating data...")
    row_size = 10000
    matrix_elem_size = row_size * (row_size - 1) / 2
    contents = random.sample(xrange(matrix_elem_size + 1), matrix_elem_size)
    matrixes = {}
    matrixes[
        "Python ConndensedMatrix"] = PythonCondensedMatrix.CondensedMatrix(
            contents)
    matrixes["C CondensedMatrix"] = CondensedMatrix(contents)
    matrixes[
        "CythonCondensedMatrix"] = CythonCondensedMatrixes.CythonCondensedMatrix(
            contents)
    matrixes[
        "CythonCondensedMatrixWithDiagonal"] = CythonCondensedMatrixes.CythonCondensedMatrixWithDiagonal(
            contents)

    print("========================")
    print("Serial access Benchmark")
    print("========================")

    for matrix_type in matrixes:
        irange = range(row_size)
        jrange = range(row_size)
from pyRMSD.condensedMatrix import CondensedMatrix
import pyRMSD.benchmark.alias.condensedMatrix as PythonCondensedMatrix
from pyRMSD.benchmark.alias.neighbourOps import choose_node_with_higher_cardinality,\
    get_neighbors_for_node

if __name__ == '__main__':

    print("Creating data...")
    row_size = 20000
    matrix_elem_size = row_size * (row_size - 1) / 2
    contents = numpy.array(
        random.sample(xrange(matrix_elem_size + 1), matrix_elem_size))
    float_contents = contents / float(max(contents))
    del contents
    matrix = CondensedMatrix(float_contents)
    matrix2 = PythonCondensedMatrix.CondensedMatrix(float_contents)
    remaining_nodes = range(row_size)

    print("======================================")
    print("'get_neighbors_for_node' benchmark")
    print("======================================")
    time_start = time.time()
    neighbors1 = matrix.get_neighbors_for_node(1, remaining_nodes, 0.5)
    time_end = time.time()
    print("Fast Neighbor search for Fast matrix took %.3fs" %
          (time_end - time_start))

    time_start = time.time()
    neighbors2 = matrix2.get_neighbors_for_node(1, remaining_nodes, 0.5)
    time_end = time.time()
    print("Slow Neighbor search for Slow matrix took %.3fs" %