forked from RoyiAvital/MatlabJuliaMatrixOperationsBenchmark
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JuliaMain.jl
57 lines (52 loc) · 2.03 KB
/
JuliaMain.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
cd(dirname(@__FILE__))
clearconsole();
# ]add BenchmarkTools
# ]add MAT
using BenchmarkTools # for benchmark
const BenchmarkTools.DEFAULT_PARAMETERS.samples = 700;
const BenchmarkTools.DEFAULT_PARAMETERS.evals = 1;
using DelimitedFiles # for readdlm, writedlm
using Statistics # for median
using LinearAlgebra # for eigen, pinv, svd, cholesky
using Random # for randperm
using MAT
const operationMode = 2; # 0 for test only # 1 for partial benchmark # 2 for full benchmark
# Julia
include("JuliaBench.jl");
tRunTime, mRunTime= JuliaBench(operationMode);
# Main RunTime Table write
writedlm("RunTimeData\\RunTimeJulia$(BLAS.vendor())Table.csv", tRunTime,',');
# RunTime save
file = matopen("RunTimeData\\RunTimeJulia$(BLAS.vendor()).mat", "w")
write(file, "mRunTime", mRunTime)
close(file)
# Julia SIMD
include("JuliaBenchSIMD.jl")
tRunTime, mRunTime= JuliaBenchSIMD(operationMode);
# Main RunTime Table write
writedlm("RunTimeData\\RunTimeJulia$(BLAS.vendor())SIMDTable.csv", tRunTime,',');
# RunTime save
file = matopen("RunTimeData\\RunTimeJulia$(BLAS.vendor())SIMD.mat", "w")
write(file, "mRunTime", mRunTime)
close(file)
# # Debug and performance trace
# include("JuliaBench.jl");
# matrixSize = 20;
# mX = randn(matrixSize, matrixSize);
# mY = randn(matrixSize, matrixSize);
# allFunctions = [MatrixGeneration, MatrixAddition, MatrixMultiplication, MatrixQuadraticForm, MatrixReductions, ElementWiseOperations, MatrixExp, MatrixSqrt, Svd, Eig, CholDec, MatInv, LinearSystem, LeastSquares, CalcDistanceMatrix, KMeans];
# # debug the code
# # Juno.@enter allFunctions[2](matrixSize, mX, mY) # copy paste to REPL
# # timing and memory
# @time allFunctions[2](matrixSize, mX, mY)
# # bad practices used in coding
# # Juno.@trace allFunctions[1](matrixSize, mX, mY)
# # profiles the code
# # using Profile
# # Profile.clear();
# # @profile allFunctions[2](matrixSize, mX, mY)
# # Profile.print(combine = true)
# # profiletree=Juno.profiletree()
# # Juno.profiler()
# # advanced tool for diagnosing type-related problems
# # @code_warntype allFunctions[2](matrixSize, mX, mY)