node.js 시스템을 벤치마킹하고 싶습니다. 그러므로 나는 파일을 암호화하고 압축 할 수있는 작은 프로그램을 만들었다. (나는 앱이 CPU를 강렬하게하고 싶어한다.) 나는 내가 여러 번 암호화 과정을 반복 할 수 있다고 생각했다. 그러나 프로그램을 끝내기 전에 스트림을 동적으로 파이프하고자 할 때마다. 스트림이 끝날 때까지 기다릴 수있는 방법이 있습니까?Node.js가 파이프 된 스트림을 동적으로 확장합니다.
내 코드는 다음과 같습니다
for (i = 0; i < algorithmCount; i++) {
stream = stream.pipe(encryptStream);
}
이 .pipe
returns the stream you're piping into 있음을 기억
var readStream = fstream.Reader(sourcePath);
var writeStream = fs.createWriteStream(sourcePath + '.tar.gz');
var stream = readStream.on('error', function (e) {
handleError(e, errorMessageReadFile);
})
.pipe(tar.Pack()).on('error', function (e) {
handleError(e, errorMessageTarPack);
});
for (i = 0; i < algorithmCount; i++) {
stream = stream.pipe(encryptStream).on('error', function (e) {
handleError(e, errorMessageEncrypt);
});
console.log("enc");
}
stream.pipe(gzip).on('error', function (e) {
handleError(e, errorMessageCompress);
})
.pipe(writeStream).on('error', function (e) {
handleError(e, errorMessageWriteFile);
})
.on('finish', function() {
console.log('done');
});
감사합니다. 나는 그것에 대해 생각하지 않았습니다. – warch