Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using BenchmarkTools;
- using LinearAlgebra;
- using Statistics;
- function SimpleMatrixOperation( mX )
- mY = (2 .* mX) + (mX .^ 2);
- mA, mB = eigen(mX);
- svdF = svd(mX);
- return mY .+ mA .+ mB .+ svdF.U;
- end
- function MeasureTimeIterations( mX, numIterations )
- vRunTime = zeros(numIterations);
- for ii = 1:numIterations
- vRunTime[ii] = @elapsed begin
- mA = SimpleMatrixOperation(mX);
- end
- end
- runTime = minimum(vRunTime);
- return runTime;
- end
- function MeasureTimeBelapsed( mX )
- runTime = @belapsed SimpleMatrixOperation(mX);
- return runTime;
- end
- matrixSize = 500;
- numIterations = 7;
- mX = randn(matrixSize, matrixSize);
- runTimeA = MeasureTimeIterations(mX, numIterations);
- runTimeB = MeasureTimeIterations(mX, 10 * numIterations);
- runTimeC = MeasureTimeBtime(mX);
- @btime SimpleMatrixOperation($mX)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement