|
|
9 meses atrás | |
|---|---|---|
| .. | ||
| BarcodeReader.cpp | 9 meses atrás | |
| BarcodeWriter.cpp | 9 meses atrás | |
| CMakeLists.txt | 9 meses atrás | |
| README.md | 9 meses atrás | |
| demo_cam_reader.html | 9 meses atrás | |
| demo_reader.html | 9 meses atrás | |
| demo_writer.html | 9 meses atrás | |
emcmake cmake <path to zxing-cpp.git/wrappers/wasm>.cmake --build . to create zxing.js and zxing.wasm (and _reader/_writer versions).emrun --serve_after_close demo_reader.html.You can also download the latest build output from the continuous integration system from the Actions tab. Look for 'wasm-artifacts'. Also check out the live demos.
There is an alternative (external) wrapper project called zxing-wasm. It is written in TypeScript, has a more feature complete interface closer to the C++ API, spares you from dealing with WASM intricacies and is provided as a fully fledged ES module on npmjs.
It turns out that compiling the library with the -Os (MinSizeRel) flag causes a noticible performance penalty. Here are some measurements from the demo_cam_reader (performed on Chromium 109 running on a Core i9-9980HK):
| | -Os | -Os -flto | -O3 | -O3 -flto | Build system |
|---------|-------|-------------|--------|-------------|-|
| size | 790kB | 950kb | 940kb | 1000kB | All |
| runtime | 320ms | 30ms | 8ms | 8ms | C++17, emsdk 3.1.9 |
| runtime | 13ms | 30ms | 8ms | 8ms | C++17, emsdk 3.1.31 |
| runtime | 46ms | 46ms | 11ms | 11ms | C++20, emsdk 3.1.31 |
Conclusions:
-flto) is not worth it and potentially even counter productive