secret
Created

  • Download Gist
Makefile
Makefile
1 2 3 4 5 6 7 8 9 10 11 12 13
.PHONY: timeit
 
timeit: geoff.py geoff.m geoff
@./geoff
@python geoff.py
@octave geoff.m
 
# 9.02029
# 2.83632302284
# 2.10921
 
geoff: geoff.cpp Makefile
g++ -O2 $< -lopencv_core -o $@
geoff.cpp
C++
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
#include <opencv2/opencv.hpp>
 
int main(void) {
using namespace cv;
 
Mat m(8192, 81, CV_32FC1);
randu(m, Scalar(0), Scalar(1));
int64 tic = getTickCount();
Mat m2 = m * m.t();
std::cout << (getTickCount() - tic) / getTickFrequency() << std::endl;
}
geoff.m
Matlab
1 2 3 4
m = rand(8192, 81);
tic;
result = m * m';
toc;
geoff.py
Python
1 2 3 4 5 6 7
import numpy as np
from timeit import default_timer as timer
 
m = np.random.rand(8192, 81)
tic = timer()
result = np.dot(m, m.T)
print (timer() - tic)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.