-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


[ ] Node.js

, 12 2017 . 15:53 +
Shvab 15:53

Node.js

Episode 8: Interview with Ryan Dahl, Creator of Node.js , Node.js, .


(fs.readFileSync ) JS .


JS (, fs.readFile).


blocking vs non-blocking .


Node.js , child_process cluster .


, .


3.3 kB 10 000


Symbol Name ops/sec Percents
A Loop readFileSync 7.4 100%
B Promise chain readFileSync 4.47 60%
C Promise chain readFile 1.09 15%
D Promise.all readFileSync 4.58 62%
E Promise.all readFile 1.69 23%
F Multithread loop readFileSync 1.35 18%

3.3 kB 100


Symbol Name ops/sec Percents
A Loop readFileSync 747 100%
B Promise chain readFileSync 641 86%
C Promise chain readFile 120 16%
D Promise.all readFileSync 664 89%
E Promise.all readFile 238 32%
F Multithread loop readFileSync 1.55 0.2%

6.5 MB 100


Symbol Name ops/sec Percents
A Loop readFileSync 0.63 83%
B Promise chain readFileSync 0.66 87%
C Promise chain readFile 0.61 80%
D Promise.all readFileSync 0.66 87%
E Promise.all readFile 0.76 100%
F Multithread loop readFileSync 0.56 74%

3.3 kB 10 000 ( Multithread loop readFileSync)


file.txt, reading 10000 times


6.5 MB 100


bigFile.txt, reading 100 times


fs.readFileSync . fs.readFile , . fs.readFileSync fs.readFile, fs.readFile fs.readFileSync.


, fs.readFileSync, fs.readFile ( ).


fs.readFileSync . . child_process. , , .


.


T1. (P1 P2) ( ). fs.readFileSync 1 :


P1 -> P2


fs.readFile 1 :


P1-1 -> P2-1 -> P1-2 -> P2-2


P1-1, P2-1 , P1-2, P2-2 .


. . , .

Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/337746/

:  

: [1] []
 

:
: 

: ( )

:

  URL