Skip to content

Instantly share code, notes, and snippets.

@aG0aep6G
Created September 2, 2015 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aG0aep6G/deee2872969fb07c2d98 to your computer and use it in GitHub Desktop.
Save aG0aep6G/deee2872969fb07c2d98 to your computer and use it in GitHub Desktop.
import std.array: replicate;
import std.conv;
import std.datetime;
import std.stdio;
void main()
{
enum size = 1024 * 1024 * 10; /* 10 MB */
go("a", size);
go("ä", size);
go("aaaaaaaaä", size);
}
void go(string s, uint totalSize)
{
assert(totalSize % s.length == 0);
File fw = File("test.txt", "w");
fw.rawWrite(s.replicate(totalSize / s.length));
fw.close();
File fr = File("test.txt", "r");
StopWatch sw;
sw.start();
auto ltr = LockingTextReader(fr);
foreach(x; ltr) {}
sw.stop();
writeln("\"", s, "\" ", to!Duration(sw.peek));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment