Posts

Project - Stage 2.3 - After Optimize

Previous Reading Project Optimize 1 & 2

Performance Test After Changes Copy the project as new
$ cp -r ~/qrcode/. ~/new

$ cd new
$ make
$ time ./new -v images/QR_damaged.png > output.html 

Do the same thing on

$ ssh siwen@aarchie.cdot.systems
$ git clone https://github.com/SiwenFeng/qrcode.git
$ cd qrcode
$ make
$ time ./qrcode -v images/QR_damaged.png > output.html 
Make the changes, then
$ cp -r ~/qrcode/. ~/new
$ cd new
$ make
$ time ./new -v images/QR_damaged.png > output.html 



Project - Stage 2.2 - Project Optimize 2

Image
Previous Reading Project Optimize Plan

The Second Algorithm Improvement In general, multiply or divide by an integer can get the result by shifting it. The multiply and divide method - generate left-shifted code if multiply by 2n, and multiply by any other integer or divide by any number. The shift method is more efficient than the multiplication and division method.

binarize.c

Project - Stage 2.1 - Project Optimize 1

Image
Previous Reading Project Optimize Plan

The First Algorithm Improvement Bit operation only needs an instruction cycle to complete, and most of the C compiler "%" operation is to call subroutines to complete, the code is long, slow execution speed. In general, as long as the remainder of 2n square is sought, the method of bit operation can be used instead.
codewordmask.c

size % 4size & 3




Project - Stage 1.0 - Project Optimize Plan

Previous Reading  Background Learning

Project Performance Test Server used in this test is Aarch64
$ ssh siwen@aarchie.cdot.systems

Fork and Clone from Github
$ git clone https://github.com/SiwenFeng/qrcode.git
$ cd qrcode

Makefile
$ make

Benchmarking tool I am going to use is time. This project is about decoding, the faster the project can read a given QR code, the better the performance is. Because it is a local testing, the network speed has been ignored.
$ time ./qrcode -v images/QR_damaged.png > output.html 

Project Code Reading The original vision code is good enough to me. It contains almost every aspect I have learned about QR code. The decoding process include some repeat calculate. I guess change the way of calculation may influence the performance.

Project Optimize Strategy

The strategy I will use in Stage 2 to attempt to optimize is Algorithm improvements.

Project - Stage 0.2 - Background Learning

Image
Previous Reading Project Selection

Some Resources - Resources list from the author
https://en.wikipedia.org/wiki/QR_code : general information about QR codes, to get startedhttps://github.com/zxing/zxing : this is a very popular encoder+decoder project written in Java that supports many types of codes, not just QR codes. The image binarization and error correction are almost direct ports of zxing's implementationhttps://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders : a nice walkthrough of how QR codes workhttps://github.com/nurse/nkf : a Kanji converter used to implement the Shift JIS decoderhttps://encoding.spec.whatwg.org/ : the reference used to implement the Big5, EUC-KR and GB18030 decodershttps://ftp.unicode.org/Public/MAPPINGS/ISO8859/ : the reference conversion tables for the ISO-8859-XX decodershttps://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/ : the reference conversion tables for the CPXXX decoders - Other resource I read in Chinese 
https://coolshel…