Thursday, January 14, 2016

Toggle CHIPs LED though REST via node.js

Thought I'd make a quick test running node.js on the chip and what better way than to blink the on-board LED which is accessible on the i2c-bus :)
Clone https://github.com/larsenglund/chipled and cd into the repository folder, then make some binaries to toggle the LED:s (from http://wiki.geeky-boy.com/w/index.php?title=CHIP_Proj1)
sudo apt-get update  # Repair things that that seem to be a little sick.
sudo apt-get upgrade
sudo apt-get install -f locales
sudo locale-gen en_US en_US.UTF-8
sudo dpkg-reconfigure locales    # Select "en_US" locales.
sudo apt-get install gcc make  # Get the C compiler

sudo gcc -o on on.c  # Compile
sudo gcc -o off off.c
sudo chmod +s on  # Allow executables to run with root privilage
sudo chmod +s off
Install node.js, npm and dependecies for the project
sudo apt-get install nodejs
sudo apt-get install npm
npm install
And start the server
nodejs chipled.js
You should now be able to toggle the white on-board LED using the following URLs:
Time to build something a bit more interesting with this CHIP :)

Read more about CHIP at the Next Thing Co (NTC) website:http://getchip.com/pages/chip

CHIP benchmarks compared to Raspberry PI and others

Got my CHIPs from Next Thing Co (NTC) yesterday and just did some quick benchmarks with sysbench to compare the CHIP to these numbers: http://www.davidhunt.ie/raspberry-pi-2-benchmarked/


In summary

* CPU 284s (about 1.8 times faster than RPi1, about 4 times slower than RPi2)
* Memory 1.76s (about 3.5 times faster than RPi1 and even faster than RPi2)
* Storage Random Write 2.76s (about twice as fast as RPi1, about the same as RPi2)
* Storage Random Read 0.65s (about twice as fast as RPi1, three times slower than RPi2)

Raw output:
chip@chip:~$ sysbench --test=cpu run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Doing CPU performance benchmark
Threads started!
Done.
Maximum prime number checked in CPU test: 10000
Test execution summary:
total time: 284.4328s
total number of events: 10000
total time taken by event execution: 284.4149
per-request statistics:
min: 28.10ms
avg: 28.44ms
max: 52.67ms
approx. 95 percentile: 28.83ms
Threads fairness:
events (avg/stddev): 10000.0000/0.00
execution time (avg/stddev): 284.4149/0.00
chip@chip:~$ sysbench --test=memory --memory-block-size=1M --memory-total-size=10G --num-threads=1 run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Doing memory operations speed test
Memory block size: 1024K
Memory transfer size: 2048M
Memory operations type: write
Memory scope type: global
Threads started!
Done.
Operations performed: 2048 ( 1166.78 ops/sec)
2048.00 MB transferred (1166.78 MB/sec)
Test execution summary:
total time: 1.7553s
total number of events: 2048
total time taken by event execution: 1.7505
per-request statistics:
min: 0.83ms
avg: 0.85ms
max: 2.91ms
approx. 95 percentile: 0.86ms
Threads fairness:
events (avg/stddev): 2048.0000/0.00
execution time (avg/stddev): 1.7505/0.00
chip@chip:~$ sysbench --test=fileio --file-test-mode=rndwr --file-total-size=16MB --num-threads=1 prepare
sysbench 0.4.12: multi-threaded system evaluation benchmark
128 files, 128Kb each, 16Mb total
Creating files for the test...
chip@chip:~$ sysbench --test=fileio --file-test-mode=rndwr --file-total-size=16MB --max-requests=1000 --num-threads=1 run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Extra file open flags: 0
128 files, 128Kb each
16Mb total file size
Block size 16Kb
Number of random requests for random IO: 1000
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random write test
Threads started!
Done.
Operations performed: 0 Read, 1000 Write, 1280 Other = 2280 Total
Read 0b Written 15.625Mb Total transferred 15.625Mb (5.6579Mb/sec)
362.10 Requests/sec executed
Test execution summary:
total time: 2.7616s
total number of events: 1000
total time taken by event execution: 0.0524
per-request statistics:
min: 0.04ms
avg: 0.05ms
max: 0.48ms
approx. 95 percentile: 0.05ms
Threads fairness:
events (avg/stddev): 1000.0000/0.00
execution time (avg/stddev): 0.0524/0.00
chip@chip:~$ sysbench --test=fileio --file-test-mode=rndrd --file-total-size=16MB --max-requests=10000 --num-threads=1 run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Extra file open flags: 0
128 files, 128Kb each
16Mb total file size
Block size 16Kb
Number of random requests for random IO: 10000
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random read test
Threads started!
Done.
Operations performed: 10000 Read, 0 Write, 0 Other = 10000 Total
Read 156.25Mb Written 0b Total transferred 156.25Mb (239.15Mb/sec)
15305.31 Requests/sec executed
Test execution summary:
total time: 0.6534s
total number of events: 10000
total time taken by event execution: 0.6194
per-request statistics:
min: 0.03ms
avg: 0.06ms
max: 0.56ms
approx. 95 percentile: 0.06ms
Threads fairness:
events (avg/stddev): 10000.0000/0.00
execution time (avg/stddev): 0.6194/0.00
view raw gistfile1.txt hosted with ❤ by GitHub