相关疑难解决方法(0)

Shell 命令在使用管道时速度较慢,使用中间文件时速度较快

有没有人理解处理时间、使用中间文件或使用管道时的巨大差异?我在新的 debian 挤压服务器上使用标准工具将 tiff 转换为 pdf。执行此操作的标准方法是先转换为 ps。

无管:

root@web5:~# time tiff2ps test.tif > test.ps

real    0m0.860s
user    0m0.744s
sys 0m0.112s

root@web5:~# time ps2pdf13 -sPAPERSIZE=a4 test.ps > test.pdf

real    0m0.667s
user    0m0.612s
sys 0m0.060s
Run Code Online (Sandbox Code Playgroud)

配管:

root@web5:~# time tiff2ps test.tif | ps2pdf13 -sPAPERSIZE=a4 - > test.pdf

real    1m6.098s
user    0m15.861s
sys 0m50.9
Run Code Online (Sandbox Code Playgroud)

在最后一条命令期间,gs 进程始终处于 100%。

更新
这是 ps 生成的 strace 输出:

root@web5:~# strace tiff2ps test.tif > test.ps
execve("/usr/bin/tiff2ps", ["tiff2ps", "test.tif"], [/* 28 vars */]) = 0
brk(0)                                  = 0x1395000
access("/etc/ld.so.nohwcap", F_OK) …
Run Code Online (Sandbox Code Playgroud)

scripting linux bash pipe shell-scripting

20
推荐指数
1
解决办法
4284
查看次数

标签 统计

bash ×1

linux ×1

pipe ×1

scripting ×1

shell-scripting ×1