www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14256] New: Poor IO performance on 64-bit dmd 2.066 (OS X)

https://issues.dlang.org/show_bug.cgi?id=14256

          Issue ID: 14256
           Summary: Poor IO performance on 64-bit dmd 2.066 (OS X)
           Product: D
           Version: unspecified
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: pmmagic gmail.com

I'm getting relatively poor I/O performance on medium to large text files in D
code compiled with DMD64 D Compiler v2.066 on OSX 10.10.2.

Below is an example D program and an equivalent Python program. The D code was
compiled with "dmd -O -release -inline -m64".

The timings on my system, when iterating over a ~470Mb file (~3.6M lines) are
as follows:


// D times
real    0m19.146s
user    0m18.932s
sys     0m0.190s

# Python times
real    0m1.544s
user    0m1.062s
sys     0m0.479s



// D code
import std.stdio;
import std.string;

int main(string[] args)
{
  if (args.length < 2) {
    return 1;
  }
  auto infile = File(args[1]);
  uint linect = 0;
  foreach (line; infile.byLine())
    linect += 1;
  writeln("There are: ", linect, " lines.");
  return 0;
}


# Python code
import sys

if __name__ == "__main__":
    if (len(sys.argv) < 2):
        sys.exit()
    infile = open(sys.argv[1])
    linect = 0
    for line in infile.readlines():
        linect += 1
    print "There are %d lines" % linect


This was originally asked on StackOverflow.  One of the respondents (username
Gassa) suggested that I file this as an issue here. See original exchange at:

http://stackoverflow.com/questions/28922323/improving-line-wise-i-o-operations-in-d

--
Mar 07 2015