forked from JulesKouatchou/basic_language_comparison
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added plotting scripts, figures and timing results
- Loading branch information
1 parent
5a58cc4
commit 0704d07
Showing
6 changed files
with
281 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/usr/bin/env python | ||
|
||
from __future__ import print_function | ||
|
||
import numpy as np | ||
import sys | ||
import matplotlib.pyplot as plt | ||
import matplotlib.pylab as pylab | ||
|
||
params = {'legend.fontsize': 'x-large', | ||
'figure.figsize': (13, 6), | ||
'figure.autolayout': True, | ||
'axes.labelsize': 'x-large', | ||
'axes.titlesize':'x-large', | ||
'xtick.labelsize':'x-large', | ||
'ytick.labelsize':'x-large'} | ||
pylab.rcParams.update(params) | ||
|
||
month="Sep2019" | ||
|
||
def get_timing(lang, test): | ||
result = None | ||
with open("../Results/timing_results_"+month+".txt", "r") as fid: | ||
lines = fid.readlines() | ||
for line in lines: | ||
if (lang in line) and (test in line): | ||
a, b, result = line.split(",") | ||
break | ||
return result | ||
|
||
languages = ["C", "Fortran", "Python", "Julia", "IDL", "Matlab", "R", "Java", "Scala"] | ||
|
||
test_cases = ["copy_matrix", "look_and_say", "iterative_fibonacci", "recursive_fibonacci", "matrix_multiplication", "evaluate_functions", "belief_propagation", "markov_chain", "laplace_equation", "munchauser_number"] | ||
|
||
num_lang = len(languages) | ||
num_test = len(test_cases) | ||
|
||
A = np.empty((num_lang,num_test,)) | ||
B = np.zeros((num_lang,num_test,)) | ||
A[:] = np.nan | ||
|
||
i = 0 | ||
for lang in languages: | ||
j = 0 | ||
for test in test_cases: | ||
result = get_timing(lang, test) | ||
if result: | ||
A[i,j] = float(result) | ||
j += 1 | ||
i += 1 | ||
|
||
A = np.ma.masked_invalid(A) | ||
|
||
for j in range(num_test): | ||
if A[0,j] == 0.0: | ||
A[:,j] = np.exp(A[:,j]) | ||
else: | ||
coef = A[0,j] | ||
A[:,j] = A[:,j] / coef | ||
|
||
|
||
data_sets = [A[j,:] for j in range(num_lang)] | ||
|
||
colors = ["blue", "orange", "green", "purple", "red", "pink", "olive", "brown", "gray"] | ||
fig, ax = plt.subplots(figsize=(15.0, 7.0)) | ||
pos = np.arange(num_test) | ||
bar_width = 0.085 | ||
i = 0 | ||
for a in data_sets: | ||
ax.bar(pos + (i+1)*bar_width, a, bar_width, color=colors[i]) | ||
i += 1 | ||
|
||
plt.yscale('log')#, nonposy='clip') | ||
|
||
ax.yaxis.grid() | ||
#plt.legend(loc='best') | ||
# Shrink current axis by 20% | ||
box = ax.get_position() | ||
ax.set_position([box.x0, box.y0, box.width * 0.8, box.height]) | ||
|
||
# Put a legend to the right of the current axis | ||
ax.legend(languages, loc='center left', bbox_to_anchor=(1, 0.5)) | ||
|
||
#plt.legend(languages, loc='upper center') | ||
ax.set_xticks(pos) | ||
ax.set_xticklabels(test_cases, rotation=45) | ||
|
||
plt.savefig("fig_languages_histo_"+month+".png", bbox_inches = "tight") | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env python | ||
|
||
from __future__ import print_function | ||
|
||
import numpy as np | ||
import sys | ||
import matplotlib.pyplot as plt | ||
import matplotlib.pylab as pylab | ||
|
||
params = {'legend.fontsize': 'x-large', | ||
'figure.figsize': (14, 6), | ||
'axes.labelsize': 'x-large', | ||
'axes.titlesize':'x-large', | ||
'xtick.labelsize':'x-large', | ||
'ytick.labelsize':'x-large'} | ||
pylab.rcParams.update(params) | ||
|
||
month="Sep2019" | ||
|
||
def get_timing(lang, test): | ||
result = None | ||
with open("../Results/timing_results_"+month+".txt", "r") as fid: | ||
lines = fid.readlines() | ||
for line in lines: | ||
if (lang in line) and (test in line): | ||
a, b, result = line.split(",") | ||
break | ||
return result | ||
|
||
languages = ["C", "Fortran", "Python", "Julia", "IDL", "Matlab", "R", "Java", "Scala"] | ||
|
||
test_cases = ["copy_matrix", "look_and_say", "iterative_fibonacci", "recursive_fibonacci", "matrix_multiplication", "evaluate_functions", "belief_propagation", "markov_chain", "laplace_equation", "munchauser_number"] | ||
|
||
colors = ["blue", "orange", "green", "purple", "red", "pink", "olive", "brown", "gray", "gold"] | ||
|
||
num_lang = len(languages) | ||
num_test = len(test_cases) | ||
|
||
A = np.empty((num_lang,num_test,)) | ||
B = np.zeros((num_lang,num_test,)) | ||
A[:] = np.nan | ||
|
||
i = 0 | ||
for lang in languages: | ||
j = 0 | ||
for test in test_cases: | ||
result = get_timing(lang, test) | ||
if result: | ||
A[i,j] = float(result) | ||
j += 1 | ||
i += 1 | ||
|
||
A = np.ma.masked_invalid(A) | ||
|
||
for j in range(num_test): | ||
if A[0,j] == 0.0: | ||
A[:,j] = np.exp(A[:,j]) | ||
else: | ||
coef = A[0,j] | ||
A[:,j] = A[:,j] / coef | ||
|
||
for j in range(num_lang): | ||
B[j,:] = B[j,:] + j | ||
|
||
fig, ax = plt.subplots(1,1) | ||
|
||
|
||
for j in range(num_test): | ||
ax.plot(B[:,j], A[:,j], "o", color=colors[j]) | ||
#ax.plot(B[:,j], A[:,j], "o", label=test_cases[j]) | ||
|
||
ax.yaxis.grid() | ||
#plt.legend(loc='best') | ||
# Shrink current axis by 20% | ||
box = ax.get_position() | ||
ax.set_position([box.x0, box.y0, box.width * 0.8, box.height]) | ||
|
||
# Put a legend to the right of the current axis | ||
ax.legend(test_cases, loc='center left', bbox_to_anchor=(1, 0.5)) | ||
#ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) | ||
|
||
ax.set_yscale('log') | ||
|
||
x = np.arange(num_lang) | ||
|
||
ax.set_xticks(x) | ||
ax.set_xticklabels(languages) #, minor=False, rotation=45) | ||
|
||
plt.savefig("fig_languages_scatter_"+month+".png") | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
|
||
C, copy_matrix, 0.29 | ||
C, look_and_say, 0.40 | ||
C, iterative_fibonacci, 0.00 | ||
C, recursive_fibonacci, 2.20 | ||
C, matrix_multiplication, 4.06 | ||
C, evaluate_functions, 116.06 | ||
C, belief_propagation, 9.72 | ||
C, markov_chain, 0.00 | ||
C, laplace_equation, 3.18 | ||
C, munchauser_number, 3.86 | ||
|
||
Fortran, copy_matrix, 0.2240 | ||
Fortran, look_and_say, 0.120 | ||
Fortran, iterative_fibonacci, 0.00 | ||
Fortran, recursive_fibonacci, 0.00 | ||
Fortran, matrix_multiplication, 0.9281 | ||
Fortran, evaluate_functions, 62.167885 | ||
Fortran, belief_propagation, 15.86499 | ||
Fortran, markov_chain, 0.00 | ||
Fortran, laplace_equation, 5.136 | ||
Fortran, munchauser_number, 21.2933 | ||
|
||
Python, copy_matrix, 1.6055 | ||
Python, look_and_say, 220.9076 | ||
Python, iterative_fibonacci, 0.00 | ||
Python, recursive_fibonacci, 1735.2580 | ||
Python, matrix_multiplication, 0.3308 | ||
Python, evaluate_functions, 18.2397 | ||
Python, belief_propagation, 13.6831 | ||
Python, markov_chain, 0.1089 | ||
Python, laplace_equation, 40.5679 | ||
Python, munchauser_number, 1121.7358 | ||
|
||
Julia, copy_matrix, 0.292153 | ||
Julia, look_and_say, 0.40 | ||
Julia, iterative_fibonacci, 0.00 | ||
Julia, recursive_fibonacci, 4.126 | ||
Julia, matrix_multiplication, 0.350375 | ||
Julia, evaluate_functions, 69.587 | ||
Julia, belief_propagation, 19.207 | ||
Julia, markov_chain, 0.00 | ||
Julia, laplace_equation, 9.5005 | ||
Julia, munchauser_number, 106.269 | ||
|
||
IDL, copy_matrix, 1.2643 | ||
IDL, look_and_say, 1612.4277 | ||
IDL, iterative_fibonacci, 0.0 | ||
IDL, recursive_fibonacci, 304.2198 | ||
IDL, matrix_multiplication, 0.3258 | ||
IDL, evaluate_functions, 35.2387 | ||
IDL, belief_propagation, 65.7071 | ||
IDL, markov_chain, 0.0157 | ||
IDL, laplace_equation, 28.0683 | ||
|
||
Matlab, copy_matrix, 0.846718 | ||
Matlab, look_and_say, 4431.342780 | ||
Matlab, iterative_fibonacci, 0.002642 | ||
Matlab, recursive_fibonacci, 150.716018 | ||
Matlab, matrix_multiplication, 0.282908 | ||
Matlab, evaluate_functions, 6.001189 | ||
Matlab, belief_propagation, 7.383720 | ||
Matlab, markov_chain, 0.043713 | ||
Matlab, laplace_equation, 8.6276 | ||
Matlab, munchauser_number, 373.785635 | ||
|
||
R, copy_matrix, 11.402 | ||
R, iterative_fibonacci, 0.032 | ||
R, recursive_fibonacci, 0.009 | ||
R, matrix_multiplication, 0.364 | ||
R, evaluate_functions, 113.929 | ||
R, belief_propagation, 89.831 | ||
R, markov_chain, 0.228 | ||
R, laplace_equation, 340.271 | ||
|
||
Java, copy_matrix, 0.590 | ||
Java, look_and_say, 0.1211 | ||
Java, iterative_fibonacci, 0.00 | ||
Java, recursive_fibonacci, 4.82112 | ||
Java, matrix_multiplication, 34.356 | ||
Java, evaluate_functions, 865.057 | ||
Java, belief_propagation, 254.377 | ||
Java, markov_chain, 0.006 | ||
Java, laplace_equation, 5.219 | ||
Java, munchauser_number, 4.8953 | ||
|
||
Scala, copy_matrix, 0.768 | ||
Scala, look_and_say, 0.189 | ||
Scala, iterative_fibonacci, 0.00 | ||
Scala, recursive_fibonacci, 5.083 | ||
Scala, matrix_multiplication, 32.1310 | ||
Scala, evaluate_functions, 446.708 | ||
Scala, belief_propagation, 212.37 | ||
Scala, markov_chain, 0.011 | ||
Scala, laplace_equation, 5.72 | ||
Scala, munchauser_number, 73.964 | ||
|