Created
November 13, 2013 10:35
-
-
Save breznak/7446953 to your computer and use it in GitHub Desktop.
NuPIC: comparing speed-mem demands of SimpleVector encoder
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
$ python VectSpeedtest.py | |
Vector creation (once) took 0 sec | |
Processing 10000 elements in big Vector took 36 sec | |
Processing 10000 elements in for-loop using small Vector took 0 sec | |
(py27)[marek@beruska nupic]$ python VectSpeedtest.py | |
Vector creation (once) took 0 sec | |
Processing 100000 elements in big Vector took 374 sec | |
Processing 100000 elements in for-loop using small Vector took 5 sec |
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
from nupic.encoders.multi import SimpleVector as Vec | |
import time | |
mx=10**5 | |
start=time.time() | |
#create big Vector | |
v = Vec(mx,0,100) | |
stop=time.time() | |
#create a small - single enc- Vector | |
v1 = Vec(1,0,100) | |
print("Vector creation (once) took %d sec" % (stop-start)) | |
#create data | |
load=[] | |
for i in xrange(0,mx): | |
load.append(1) | |
#V1: process 10^7 elements using big Vector | |
start=time.time() | |
enc=v.encode(load) | |
dec=v.decode(enc) | |
stop=time.time() | |
print("Processing %d elements in big Vector took %d sec" % (mx, (stop-start))) | |
#V2: process 10^7 elements using loop and single encoder | |
start=time.time() | |
loadd=[1] | |
for i in xrange(0,mx): | |
enc=v1.encode(loadd) | |
dec=v1.decode(enc) | |
stop=time.time() | |
print("Processing %d elements in for-loop using small Vector took %d sec" % (mx, (stop-start))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment