Reading from stdin significantly slower than reading file directly?
methonash
herp at derp.com
Wed Aug 12 22:44:44 UTC 2020
Hi,
Relative beginner to D-lang here, and I'm very confused by the
apparent performance disparity I've noticed between programs that
do the following:
1) cat some-large-file | D-program-reading-stdin-byLine()
2) D-program-directly-reading-file-byLine() using File() struct
The D-lang difference I've noticed from options (1) and (2) is
somewhere in the range of 80% wall time taken (7.5s vs 4.1s),
which seems pretty extreme.
For comparison, I attempted the same using Perl with the same
large file, and I only noticed a 25% difference (10s vs 8s) in
performance, which I imagine to be partially attributable to the
overhead incurred by using a pipe and its buffer.
So, is this difference in D-lang performance typical? Is this
expected behavior?
Was wondering if this may have anything to do with the library
definition for std.stdio.stdin
(https://dlang.org/library/std/stdio/stdin.html)? Does global
file-locking significantly affect read-performance?
For reference: I'm trying to build a single-threaded application;
my present use-case cannot benefit from parallelism, because its
ultimate purpose is to serve as a single-threaded downstream
filter from an upstream application consuming (n-1) system
threads.
More information about the Digitalmars-d-learn
mailing list