Closed alias-rahil closed 4 years ago
I have run a node script with a profiler to look where most of the time was spent. https://nodejs.org/en/docs/guides/simple-profiling/
The script I have try:
const handwritten = require('handwritten.js')
const fs = require('fs')
const rawtext = `
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque id semper neque. Nullam cursus eros vel sapien pretium, id ultrices enim lacinia. Vestibulum nec condimentum neque. Nulla ut diam ac sapien luctus luctus sed ut odio. Aliquam sollicitudin condimentum tellus, a suscipit lectus sagittis nec. Nulla neque turpis, lacinia a felis tempor, fringilla ultricies lorem. Ut aliquam enim id nisi efficitur, vel feugiat erat pellentesque. Sed ultricies semper suscipit. Vestibulum egestas arcu sed magna tincidunt, a consequat arcu porta. Aliquam consequat mi a dui tincidunt sollicitudin vitae non libero.
`
handwritten(rawtext).then((converted) => {
converted.pipe(fs.createWriteStream('output.pdf'))
}).then(()=> console.log('ended'))
I am not an expert of node log profile but at first it seems that it's pngjs, jimp and pdfkit that takes most of the time. I don't think fs is the problem here. I guess that building a pdf from a tons of images requires a lot of computation and results in heavy pdf. A more efficient way of doing thing might be to build the document with vector graphic using svg or directly pdf images of the letters
The processed logs are: processed.log
Testing v8 version different from logging version
Statistical profiling result from log, (3133 ticks, 1 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
1794 57.3% /usr/local/bin/node
181 5.8% /lib/x86_64-linux-gnu/libc-2.24.so
37 1.2% /lib/x86_64-linux-gnu/libpthread-2.24.so
1 0.0% /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
[JavaScript]:
ticks total nonlib name
274 8.7% 24.5% LazyCompile: *pass /node_modules/png-js/png-node.js:195:20
164 5.2% 14.6% LazyCompile: *filterSumPaeth /node_modules/pngjs/lib/filter-pack.js:114:24
143 4.6% 12.8% LazyCompile: *filterPaeth /node_modules/pngjs/lib/filter-pack.js:101:21
108 3.4% 9.6% LazyCompile: *Resize.resizeHeightInterpolated /node_modules/@jimp/plugin-resize/dist/modules/resize.js:291:54
82 2.6% 7.3% LazyCompile: *<anonymous> /node_modules/pdfkit/js/pdfkit.js:4362:36
67 2.1% 6.0% LazyCompile: *filterSumAvg /node_modules/pngjs/lib/filter-pack.js:86:22
50 1.6% 4.5% LazyCompile: *filterSumSub /node_modules/pngjs/lib/filter-pack.js:34:22
42 1.3% 3.8% LazyCompile: *filterSumUp /node_modules/pngjs/lib/filter-pack.js:59:21
37 1.2% 3.3% LazyCompile: *Resize._resizeWidthInterpolatedRGBChannels /node_modules/@jimp/plugin-resize/dist/modules/resize.js:64:65
29 0.9% 2.6% LazyCompile: *filterSumNone /node_modules/pngjs/lib/filter-pack.js:12:23
20 0.6% 1.8% LazyCompile: *<anonymous> /node_modules/@jimp/core/dist/composite/index.js:69:69
11 0.4% 1.0% RegExp: ^data:.+;base64,(.*)$
11 0.4% 1.0% LazyCompile: *PNG /node_modules/png-js/png-node.js:37:14
9 0.3% 0.8% LazyCompile: *getPixelIndex /node_modules/@jimp/core/dist/index.js:713:34
8 0.3% 0.7% LazyCompile: *filterUp /node_modules/pngjs/lib/filter-pack.js:48:18
8 0.3% 0.7% LazyCompile: *decodeHuffman /node_modules/jpeg-js/lib/decoder.js:121:27
8 0.3% 0.7% LazyCompile: *CrcCalculator.crc32 /node_modules/pngjs/lib/crc.js:37:31
6 0.2% 0.5% LazyCompile: *readBit /node_modules/jpeg-js/lib/decoder.js:105:21
5 0.2% 0.4% LazyCompile: *mapImage8Bit /node_modules/pngjs/lib/bitmapper.js:173:22
4 0.1% 0.4% LazyCompile: *parse /node_modules/jpeg-js/lib/decoder.js:564:26
4 0.1% 0.4% LazyCompile: *Jimp /node_modules/@jimp/core/dist/index.js:215:16
3 0.1% 0.3% LazyCompile: *quantizeAndInverse /node_modules/jpeg-js/lib/decoder.js:370:32
2 0.1% 0.2% RegExp: ^(.*)[\\/]node_modules[\\/]
2 0.1% 0.2% LazyCompile: *scan /node_modules/@jimp/utils/dist/index.js:43:14
2 0.1% 0.2% LazyCompile: *resolve path.js:973:10
2 0.1% 0.2% LazyCompile: *getData /node_modules/jpeg-js/lib/decoder.js:855:30
2 0.1% 0.2% LazyCompile: *decodeScan /node_modules/jpeg-js/lib/decoder.js:93:22
2 0.1% 0.2% LazyCompile: *concat buffer.js:546:32
2 0.1% 0.2% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
2 0.1% 0.2% LazyCompile: *Filter._unFilterType4 /node_modules/pngjs/lib/filter-parse.js:103:43
2 0.1% 0.2% LazyCompile: *Filter._unFilterType2 /node_modules/pngjs/lib/filter-parse.js:77:43
1 0.0% 0.1% RegExp: ^\/|\\
1 0.0% 0.1% LazyCompile: *structuredStack structured-stack:3:38
1 0.0% 0.1% LazyCompile: *receive /node_modules/jpeg-js/lib/decoder.js:132:21
1 0.0% 0.1% LazyCompile: *processCallback zlib.js:507:25
1 0.0% 0.1% LazyCompile: *copyToImageData /node_modules/jpeg-js/lib/decoder.js:979:46
1 0.0% 0.1% LazyCompile: *buildHuffmanTable /node_modules/jpeg-js/lib/decoder.js:59:29
1 0.0% 0.1% LazyCompile: *SyncReader.read /node_modules/pngjs/lib/sync-reader.js:9:37
1 0.0% 0.1% LazyCompile: *CrcCalculator.write /node_modules/pngjs/lib/crc.js:24:41
[C++]:
ticks total nonlib name
[Summary]:
ticks total nonlib name
1119 35.7% 99.9% JavaScript
0 0.0% 0.0% C++
80 2.6% 7.1% GC
2013 64.3% Shared libraries
1 0.0% Unaccounted
[C++ entry points]:
ticks cpp total name
[Bottom up (heavy) profile]:
Note: percentage shows a share of a particular caller in the total
amount of its parent calls.
Callers occupying less than 1.0% are not shown.
ticks parent name
1794 57.3% /usr/local/bin/node
1404 78.3% /usr/local/bin/node
661 47.1% LazyCompile: ~processChunkSync zlib.js:404:26
661 100.0% LazyCompile: ~zlibBufferSync zlib.js:152:24
661 100.0% LazyCompile: ~syncBufferWrapper zlib.js:763:38
540 81.7% LazyCompile: ~<anonymous> /node_modules/pdfkit/js/pdfkit.js:4362:36
121 18.3% LazyCompile: ~module.exports /node_modules/pngjs/lib/packer-sync.js:11:26
146 10.4% LazyCompile: *FastBuffer internal/buffer.js:945:1
146 100.0% LazyCompile: ~fromArrayLike buffer.js:490:23
146 100.0% LazyCompile: ~fromObject buffer.js:505:20
146 100.0% LazyCompile: ~from buffer.js:304:28
104 7.4% /usr/local/bin/node
82 78.8% LazyCompile: *FastBuffer internal/buffer.js:945:1
80 97.6% LazyCompile: ~fromArrayLike buffer.js:490:23
80 100.0% LazyCompile: ~fromObject buffer.js:505:20
2 2.4% LazyCompile: ~createUnsafeBuffer buffer.js:147:28
2 100.0% LazyCompile: ~allocate buffer.js:408:18
3 2.9% LazyCompile: ~prepareComponents /node_modules/jpeg-js/lib/decoder.js:578:33
2 66.7% LazyCompile: ~parse /node_modules/jpeg-js/lib/decoder.js:564:26
2 100.0% LazyCompile: ~decode /node_modules/jpeg-js/lib/decoder.js:1078:16
1 33.3% LazyCompile: *parse /node_modules/jpeg-js/lib/decoder.js:564:26
1 100.0% LazyCompile: ~decode /node_modules/jpeg-js/lib/decoder.js:1078:16
2 1.9% LazyCompile: ~structuredStack structured-stack:3:38
1 50.0% LazyCompile: *isInsideNodeModules internal/util.js:353:29
1 100.0% LazyCompile: ~showFlaggedDeprecation buffer.js:178:32
1 50.0% LazyCompile: *Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
1 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
2 1.9% LazyCompile: ~<anonymous> /node_modules/handwritten.js/src/index.js:185:30
2 100.0% /usr/local/bin/node
2 100.0% LazyCompile: ~<anonymous> /node_modules/handwritten.js/src/index.js:183:18
2 1.9% LazyCompile: *structuredStack structured-stack:3:38
2 100.0% LazyCompile: *Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
2 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
2 1.9% Eval: ~<anonymous> /node_modules/brotli/dec/dictionary-data.js:1:1
2 100.0% LazyCompile: ~Module._compile internal/modules/cjs/loader.js:1091:37
2 100.0% LazyCompile: ~Module._extensions..js internal/modules/cjs/loader.js:1146:37
71 5.1% LazyCompile: ~wrapSafe internal/modules/cjs/loader.js:1037:18
71 100.0% LazyCompile: ~Module._compile internal/modules/cjs/loader.js:1091:37
71 100.0% LazyCompile: ~Module._extensions..js internal/modules/cjs/loader.js:1146:37
71 100.0% LazyCompile: ~Module.load internal/modules/cjs/loader.js:973:33
63 4.5% LazyCompile: *structuredStack structured-stack:3:38
36 57.1% LazyCompile: *Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
36 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
36 100.0% LazyCompile: ~exports.process /node_modules/pngjs/lib/filter-parse-sync.js:7:27
16 25.4% LazyCompile: *isInsideNodeModules internal/util.js:353:29
16 100.0% LazyCompile: ~showFlaggedDeprecation buffer.js:178:32
16 100.0% LazyCompile: ~Buffer buffer.js:278:16
11 17.5% LazyCompile: *Buffer buffer.js:278:16
8 72.7% LazyCompile: ~Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
8 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
3 27.3% LazyCompile: ~Parser._parseChunkBegin /node_modules/pngjs/lib/parser.js:60:45
3 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
49 3.5% LazyCompile: *PNG /node_modules/png-js/png-node.js:37:14
49 100.0% LazyCompile: ~PNGImage /node_modules/pdfkit/js/pdfkit.js:4249:14
49 100.0% LazyCompile: ~open /node_modules/pdfkit/js/pdfkit.js:4419:14
49 100.0% LazyCompile: ~openImage /node_modules/pdfkit/js/pdfkit.js:4567:12
34 2.4% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
34 100.0% LazyCompile: ~nativeModuleRequire internal/bootstrap/loaders.js:297:29
5 14.7% Eval: ~<anonymous> internal/bootstrap/node.js:1:1
3 8.8% LazyCompile: ~setupPrepareStackTrace internal/bootstrap/node.js:251:32
3 100.0% Eval: ~<anonymous> internal/bootstrap/node.js:1:1
3 8.8% Eval: ~<anonymous> stream.js:1:1
3 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
3 8.8% Eval: ~<anonymous> events.js:1:1
3 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
2 5.9% Eval: ~<anonymous> internal/modules/esm/loader.js:1:1
2 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
2 5.9% Eval: ~<anonymous> http.js:1:1
2 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
1 2.9% LazyCompile: ~setupProcessObject internal/bootstrap/node.js:270:28
1 100.0% Eval: ~<anonymous> internal/bootstrap/node.js:1:1
1 2.9% LazyCompile: ~setupBuffer internal/bootstrap/node.js:329:21
1 100.0% Eval: ~<anonymous> internal/bootstrap/node.js:1:1
1 2.9% LazyCompile: ~lazyLoadStreams fs.js:1885:25
1 100.0% LazyCompile: ~get ReadStream fs.js:1988:17
1 2.9% LazyCompile: ~initializeCJSLoader internal/bootstrap/pre_execution.js:399:29
1 100.0% LazyCompile: ~prepareMainThreadExecution internal/bootstrap/pre_execution.js:14:36
1 2.9% Eval: ~<anonymous> tls.js:1:1
1 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
1 2.9% Eval: ~<anonymous> internal/url.js:1:1
1 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
1 2.9% Eval: ~<anonymous> internal/source_map/source_map_cache.js:1:1
1 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
1 2.9% Eval: ~<anonymous> internal/process/task_queues.js:1:1
1 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
1 2.9% Eval: ~<anonymous> internal/modules/cjs/loader.js:1:1
1 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
1 2.9% Eval: ~<anonymous> internal/modules/cjs/helpers.js:1:1
1 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
1 2.9% Eval: ~<anonymous> internal/crypto/keygen.js:1:1
1 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
1 2.9% Eval: ~<anonymous> buffer.js:1:1
1 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
1 2.9% Eval: ~<anonymous> assert.js:1:1
1 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
1 2.9% Eval: ~<anonymous> _tls_wrap.js:1:1
1 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
1 2.9% Eval: ~<anonymous> _http_client.js:1:1
1 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
1 2.9% Eval: ~<anonymous> _http_agent.js:1:1
1 100.0% LazyCompile: ~compileForInternalLoader internal/bootstrap/loaders.js:264:27
24 1.7% LazyCompile: ~structuredStack structured-stack:3:38
12 50.0% LazyCompile: *isInsideNodeModules internal/util.js:353:29
12 100.0% LazyCompile: ~showFlaggedDeprecation buffer.js:178:32
12 100.0% LazyCompile: ~Buffer buffer.js:278:16
9 37.5% LazyCompile: *Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
9 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
9 100.0% LazyCompile: ~exports.process /node_modules/pngjs/lib/filter-parse-sync.js:7:27
3 12.5% LazyCompile: ~isInsideNodeModules internal/util.js:353:29
3 100.0% LazyCompile: ~showFlaggedDeprecation buffer.js:178:32
3 100.0% LazyCompile: ~Buffer buffer.js:278:16
16 1.1% LazyCompile: ~pass /node_modules/png-js/png-node.js:195:20
16 100.0% LazyCompile: ~<anonymous> /node_modules/png-js/png-node.js:183:39
16 100.0% LazyCompile: ~zlibBufferOnEnd zlib.js:132:25
16 100.0% LazyCompile: ~emit events.js:263:44
16 1.1% LazyCompile: ~Module._extensions..json internal/modules/cjs/loader.js:1162:39
16 100.0% LazyCompile: ~Module.load internal/modules/cjs/loader.js:973:33
16 100.0% LazyCompile: ~Module._load internal/modules/cjs/loader.js:822:24
16 100.0% LazyCompile: ~Module.require internal/modules/cjs/loader.js:1017:36
49 2.7% LazyCompile: *structuredStack structured-stack:3:38
22 44.9% LazyCompile: *Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
22 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
22 100.0% LazyCompile: ~exports.process /node_modules/pngjs/lib/filter-parse-sync.js:7:27
22 100.0% LazyCompile: ~module.exports /node_modules/pngjs/lib/parser-sync.js:16:26
21 42.9% LazyCompile: *isInsideNodeModules internal/util.js:353:29
21 100.0% LazyCompile: ~showFlaggedDeprecation buffer.js:178:32
21 100.0% LazyCompile: ~Buffer buffer.js:278:16
20 95.2% LazyCompile: ~Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
1 4.8% LazyCompile: ~Parser._parseChunkBegin /node_modules/pngjs/lib/parser.js:60:45
6 12.2% LazyCompile: *Buffer buffer.js:278:16
4 66.7% LazyCompile: ~Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
4 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
4 100.0% LazyCompile: ~exports.process /node_modules/pngjs/lib/filter-parse-sync.js:7:27
2 33.3% LazyCompile: ~Parser._parseChunkBegin /node_modules/pngjs/lib/parser.js:60:45
2 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
2 100.0% LazyCompile: ~module.exports /node_modules/pngjs/lib/parser-sync.js:16:26
25 1.4% LazyCompile: ~structuredStack structured-stack:3:38
11 44.0% LazyCompile: *isInsideNodeModules internal/util.js:353:29
11 100.0% LazyCompile: ~showFlaggedDeprecation buffer.js:178:32
11 100.0% LazyCompile: ~Buffer buffer.js:278:16
9 81.8% LazyCompile: ~Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
2 18.2% LazyCompile: ~Parser._parseChunkBegin /node_modules/pngjs/lib/parser.js:60:45
9 36.0% LazyCompile: *Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
9 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
9 100.0% LazyCompile: ~exports.process /node_modules/pngjs/lib/filter-parse-sync.js:7:27
9 100.0% LazyCompile: ~module.exports /node_modules/pngjs/lib/parser-sync.js:16:26
5 20.0% LazyCompile: ~isInsideNodeModules internal/util.js:353:29
5 100.0% LazyCompile: ~showFlaggedDeprecation buffer.js:178:32
5 100.0% LazyCompile: ~Buffer buffer.js:278:16
5 100.0% LazyCompile: ~Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
274 8.7% LazyCompile: *pass /node_modules/png-js/png-node.js:195:20
274 100.0% LazyCompile: ~<anonymous> /node_modules/png-js/png-node.js:183:39
274 100.0% LazyCompile: ~zlibBufferOnEnd zlib.js:132:25
274 100.0% LazyCompile: ~emit events.js:263:44
274 100.0% LazyCompile: ~endReadableNT _stream_readable.js:1213:23
274 100.0% LazyCompile: ~processTicksAndRejections internal/process/task_queues.js:69:35
181 5.8% /lib/x86_64-linux-gnu/libc-2.24.so
125 69.1% /usr/local/bin/node
66 52.8% /usr/local/bin/node
61 92.4% LazyCompile: *FastBuffer internal/buffer.js:945:1
59 96.7% LazyCompile: ~fromArrayLike buffer.js:490:23
59 100.0% LazyCompile: ~fromObject buffer.js:505:20
1 1.6% LazyCompile: ~createUnsafeBuffer buffer.js:147:28
1 100.0% LazyCompile: ~allocate buffer.js:408:18
1 1.6% LazyCompile: ~alloc buffer.js:370:30
1 100.0% LazyCompile: ~decode /node_modules/jpeg-js/lib/decoder.js:1078:16
1 1.5% LazyCompile: ~structuredStack structured-stack:3:38
1 100.0% LazyCompile: *Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
1 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
1 1.5% LazyCompile: ~prepareComponents /node_modules/jpeg-js/lib/decoder.js:578:33
1 100.0% LazyCompile: ~parse /node_modules/jpeg-js/lib/decoder.js:564:26
1 100.0% LazyCompile: ~decode /node_modules/jpeg-js/lib/decoder.js:1078:16
1 1.5% LazyCompile: ~decode /node_modules/jpeg-js/lib/decoder.js:1078:16
1 100.0% LazyCompile: ~parseBitmap /node_modules/@jimp/core/dist/utils/image-bitmap.js:183:21
1 100.0% LazyCompile: ~parseBitmap /node_modules/@jimp/core/dist/index.js:430:32
1 1.5% LazyCompile: ~FastBuffer internal/buffer.js:945:1
1 100.0% LazyCompile: ~alloc buffer.js:370:30
1 100.0% LazyCompile: ~decode /node_modules/jpeg-js/lib/decoder.js:1078:16
1 1.5% LazyCompile: ~<anonymous> internal/per_context/primordials.js:23:10
1 100.0% LazyCompile: ~resolveExports internal/modules/cjs/loader.js:497:24
1 100.0% LazyCompile: ~Module._findPath internal/modules/cjs/loader.js:606:28
12 9.6% LazyCompile: *structuredStack structured-stack:3:38
8 66.7% LazyCompile: *Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
8 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
8 100.0% LazyCompile: ~exports.process /node_modules/pngjs/lib/filter-parse-sync.js:7:27
2 16.7% LazyCompile: *isInsideNodeModules internal/util.js:353:29
2 100.0% LazyCompile: ~showFlaggedDeprecation buffer.js:178:32
2 100.0% LazyCompile: ~Buffer buffer.js:278:16
2 16.7% LazyCompile: *Buffer buffer.js:278:16
2 100.0% LazyCompile: ~Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
2 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
11 8.8% LazyCompile: ~structuredStack structured-stack:3:38
5 45.5% LazyCompile: *isInsideNodeModules internal/util.js:353:29
5 100.0% LazyCompile: ~showFlaggedDeprecation buffer.js:178:32
5 100.0% LazyCompile: ~Buffer buffer.js:278:16
4 36.4% LazyCompile: *Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
4 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
4 100.0% LazyCompile: ~exports.process /node_modules/pngjs/lib/filter-parse-sync.js:7:27
2 18.2% LazyCompile: ~isInsideNodeModules internal/util.js:353:29
2 100.0% LazyCompile: ~showFlaggedDeprecation buffer.js:178:32
2 100.0% LazyCompile: ~Buffer buffer.js:278:16
11 8.8% LazyCompile: *concat buffer.js:546:32
7 63.6% LazyCompile: ~zlibBufferOnEnd zlib.js:132:25
7 100.0% LazyCompile: ~emit events.js:263:44
7 100.0% LazyCompile: ~endReadableNT _stream_readable.js:1213:23
2 18.2% LazyCompile: ~processChunkSync zlib.js:404:26
2 100.0% LazyCompile: ~zlibBufferSync zlib.js:152:24
2 100.0% LazyCompile: ~syncBufferWrapper zlib.js:763:38
1 9.1% LazyCompile: ~module.exports /node_modules/pngjs/lib/packer-sync.js:11:26
1 100.0% LazyCompile: ~exports.write /node_modules/pngjs/lib/png-sync.js:13:25
1 100.0% LazyCompile: ~<anonymous> /node_modules/@jimp/png/dist/index.js:39:72
1 9.1% LazyCompile: ~Inflate._processChunk /node_modules/pngjs/lib/sync-inflate.js:47:43
1 100.0% LazyCompile: ~zlibBufferSync /node_modules/pngjs/lib/sync-inflate.js:138:24
1 100.0% LazyCompile: ~inflateSync /node_modules/pngjs/lib/sync-inflate.js:154:21
6 4.8% LazyCompile: ~image /node_modules/pdfkit/js/pdfkit.js:4457:8
6 100.0% LazyCompile: ~generatePdf /node_modules/handwritten.js/src/index.js:107:27
6 100.0% /usr/local/bin/node
164 5.2% LazyCompile: *filterSumPaeth /node_modules/pngjs/lib/filter-pack.js:114:24
84 51.2% LazyCompile: *module.exports /node_modules/pngjs/lib/filter-pack.js:145:26
84 100.0% LazyCompile: ~Packer.filterData /node_modules/pngjs/lib/packer.js:55:39
84 100.0% LazyCompile: ~module.exports /node_modules/pngjs/lib/packer-sync.js:11:26
84 100.0% LazyCompile: ~exports.write /node_modules/pngjs/lib/png-sync.js:13:25
84 100.0% LazyCompile: ~<anonymous> /node_modules/@jimp/png/dist/index.js:39:72
80 48.8% LazyCompile: ~module.exports /node_modules/pngjs/lib/filter-pack.js:145:26
80 100.0% LazyCompile: ~Packer.filterData /node_modules/pngjs/lib/packer.js:55:39
80 100.0% LazyCompile: ~module.exports /node_modules/pngjs/lib/packer-sync.js:11:26
80 100.0% LazyCompile: ~exports.write /node_modules/pngjs/lib/png-sync.js:13:25
80 100.0% LazyCompile: ~<anonymous> /node_modules/@jimp/png/dist/index.js:39:72
143 4.6% LazyCompile: *filterPaeth /node_modules/pngjs/lib/filter-pack.js:101:21
72 50.3% LazyCompile: ~module.exports /node_modules/pngjs/lib/filter-pack.js:145:26
72 100.0% LazyCompile: ~Packer.filterData /node_modules/pngjs/lib/packer.js:55:39
72 100.0% LazyCompile: ~module.exports /node_modules/pngjs/lib/packer-sync.js:11:26
72 100.0% LazyCompile: ~exports.write /node_modules/pngjs/lib/png-sync.js:13:25
72 100.0% LazyCompile: ~<anonymous> /node_modules/@jimp/png/dist/index.js:39:72
71 49.7% LazyCompile: *module.exports /node_modules/pngjs/lib/filter-pack.js:145:26
71 100.0% LazyCompile: ~Packer.filterData /node_modules/pngjs/lib/packer.js:55:39
71 100.0% LazyCompile: ~module.exports /node_modules/pngjs/lib/packer-sync.js:11:26
71 100.0% LazyCompile: ~exports.write /node_modules/pngjs/lib/png-sync.js:13:25
71 100.0% LazyCompile: ~<anonymous> /node_modules/@jimp/png/dist/index.js:39:72
108 3.4% LazyCompile: *Resize.resizeHeightInterpolated /node_modules/@jimp/plugin-resize/dist/modules/resize.js:291:54
108 100.0% LazyCompile: ~Resize.resize /node_modules/@jimp/plugin-resize/dist/modules/resize.js:343:36
108 100.0% LazyCompile: ~resize /node_modules/@jimp/plugin-resize/dist/index.js:34:30
108 100.0% LazyCompile: ~<anonymous> /node_modules/handwritten.js/src/index.js:180:15
108 100.0% /usr/local/bin/node
108 100.0% LazyCompile: ~generateImageArray /node_modules/handwritten.js/src/index.js:178:28
82 2.6% LazyCompile: *<anonymous> /node_modules/pdfkit/js/pdfkit.js:4362:36
82 100.0% LazyCompile: ~<anonymous> /node_modules/png-js/png-node.js:183:39
82 100.0% LazyCompile: ~zlibBufferOnEnd zlib.js:132:25
82 100.0% LazyCompile: ~emit events.js:263:44
82 100.0% LazyCompile: ~endReadableNT _stream_readable.js:1213:23
82 100.0% LazyCompile: ~processTicksAndRejections internal/process/task_queues.js:69:35
67 2.1% LazyCompile: *filterSumAvg /node_modules/pngjs/lib/filter-pack.js:86:22
39 58.2% LazyCompile: *module.exports /node_modules/pngjs/lib/filter-pack.js:145:26
39 100.0% LazyCompile: ~Packer.filterData /node_modules/pngjs/lib/packer.js:55:39
39 100.0% LazyCompile: ~module.exports /node_modules/pngjs/lib/packer-sync.js:11:26
39 100.0% LazyCompile: ~exports.write /node_modules/pngjs/lib/png-sync.js:13:25
39 100.0% LazyCompile: ~<anonymous> /node_modules/@jimp/png/dist/index.js:39:72
28 41.8% LazyCompile: ~module.exports /node_modules/pngjs/lib/filter-pack.js:145:26
28 100.0% LazyCompile: ~Packer.filterData /node_modules/pngjs/lib/packer.js:55:39
28 100.0% LazyCompile: ~module.exports /node_modules/pngjs/lib/packer-sync.js:11:26
28 100.0% LazyCompile: ~exports.write /node_modules/pngjs/lib/png-sync.js:13:25
28 100.0% LazyCompile: ~<anonymous> /node_modules/@jimp/png/dist/index.js:39:72
50 1.6% LazyCompile: *filterSumSub /node_modules/pngjs/lib/filter-pack.js:34:22
28 56.0% LazyCompile: *module.exports /node_modules/pngjs/lib/filter-pack.js:145:26
28 100.0% LazyCompile: ~Packer.filterData /node_modules/pngjs/lib/packer.js:55:39
28 100.0% LazyCompile: ~module.exports /node_modules/pngjs/lib/packer-sync.js:11:26
28 100.0% LazyCompile: ~exports.write /node_modules/pngjs/lib/png-sync.js:13:25
28 100.0% LazyCompile: ~<anonymous> /node_modules/@jimp/png/dist/index.js:39:72
22 44.0% LazyCompile: ~module.exports /node_modules/pngjs/lib/filter-pack.js:145:26
22 100.0% LazyCompile: ~Packer.filterData /node_modules/pngjs/lib/packer.js:55:39
22 100.0% LazyCompile: ~module.exports /node_modules/pngjs/lib/packer-sync.js:11:26
22 100.0% LazyCompile: ~exports.write /node_modules/pngjs/lib/png-sync.js:13:25
22 100.0% LazyCompile: ~<anonymous> /node_modules/@jimp/png/dist/index.js:39:72
42 1.3% LazyCompile: *filterSumUp /node_modules/pngjs/lib/filter-pack.js:59:21
22 52.4% LazyCompile: ~module.exports /node_modules/pngjs/lib/filter-pack.js:145:26
22 100.0% LazyCompile: ~Packer.filterData /node_modules/pngjs/lib/packer.js:55:39
22 100.0% LazyCompile: ~module.exports /node_modules/pngjs/lib/packer-sync.js:11:26
22 100.0% LazyCompile: ~exports.write /node_modules/pngjs/lib/png-sync.js:13:25
22 100.0% LazyCompile: ~<anonymous> /node_modules/@jimp/png/dist/index.js:39:72
20 47.6% LazyCompile: *module.exports /node_modules/pngjs/lib/filter-pack.js:145:26
20 100.0% LazyCompile: ~Packer.filterData /node_modules/pngjs/lib/packer.js:55:39
20 100.0% LazyCompile: ~module.exports /node_modules/pngjs/lib/packer-sync.js:11:26
20 100.0% LazyCompile: ~exports.write /node_modules/pngjs/lib/png-sync.js:13:25
20 100.0% LazyCompile: ~<anonymous> /node_modules/@jimp/png/dist/index.js:39:72
37 1.2% LazyCompile: *Resize._resizeWidthInterpolatedRGBChannels /node_modules/@jimp/plugin-resize/dist/modules/resize.js:64:65
37 100.0% LazyCompile: ~Resize.resizeWidthInterpolatedRGBA /node_modules/@jimp/plugin-resize/dist/modules/resize.js:279:57
37 100.0% LazyCompile: ~Resize.resize /node_modules/@jimp/plugin-resize/dist/modules/resize.js:343:36
37 100.0% LazyCompile: ~resize /node_modules/@jimp/plugin-resize/dist/index.js:34:30
37 100.0% LazyCompile: ~<anonymous> /node_modules/handwritten.js/src/index.js:180:15
37 100.0% /usr/local/bin/node
37 1.2% /lib/x86_64-linux-gnu/libpthread-2.24.so
5 13.5% /usr/local/bin/node
2 40.0% LazyCompile: *structuredStack structured-stack:3:38
2 100.0% LazyCompile: *Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
2 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
2 100.0% LazyCompile: ~exports.process /node_modules/pngjs/lib/filter-parse-sync.js:7:27
1 20.0% LazyCompile: ~structuredStack structured-stack:3:38
1 100.0% LazyCompile: *Filter._reverseFilterLine /node_modules/pngjs/lib/filter-parse.js:119:47
1 100.0% LazyCompile: *SyncReader.process /node_modules/pngjs/lib/sync-reader.js:18:40
1 100.0% LazyCompile: ~exports.process /node_modules/pngjs/lib/filter-parse-sync.js:7:27
1 20.0% LazyCompile: ~normalizeString path.js:52:25
1 100.0% LazyCompile: ~resolve path.js:973:10
1 100.0% LazyCompile: ~readPackage internal/modules/cjs/loader.js:243:21
1 100.0% LazyCompile: ~readPackageScope internal/modules/cjs/loader.js:278:26
1 20.0% LazyCompile: ~WriteStream._writev internal/fs/streams.js:405:41
1 100.0% LazyCompile: ~doWrite _stream_writable.js:393:17
1 100.0% LazyCompile: ~clearBuffer _stream_writable.js:497:21
1 100.0% LazyCompile: ~onwrite _stream_writable.js:431:17
1 2.7% LazyCompile: *processCallback zlib.js:507:25
A more efficient way of doing thing might be to build the document with vector graphic using svg or directly pdf images of the letters
Okay so here is what needs to be done:
@etnnth, let me know if you want to take this up.
I can try. I have take a look at pdfkit doc and i think there is two way of doing it.
I think the simplest approach is by creating 6 different fonts and using text. What do you think about it?
I think the simplest approach is by creating 6 different fonts and using text.
This defeats the purpose of generating realistic looking handwriting. I do not want to go with the font approach. It would be better if we can generate pdf using the images available in the dataset.
Ok, I'm trying to understand, what aspect of the font approach do you think is incompatible realistic handwriting ?
Ok, I'm trying to understand, what aspect of the font approach do you think is incompatible realistic handwriting ?
The output won't look written naturally by hand.
@alias-rahil I did start working on using svg images, let me know if this is something that you may be interested in.
@alias-rahil I did start working on using svg images, let me know if this is something that you may be interested in.
Sure, assigned to you, make PR when done! Thanks!
Is your feature request related to a problem? Please describe. The library is very slow.
Describe the solution you'd like The src/bin.js uses fs related blocking sync methods. I believe that the library could be made a lot faster if we use their alternatives. Other optimizations in src/bin.js and src/index.js are also needed.
Describe alternatives you've considered
Additional context