Created
September 2, 2015 14:28
-
-
Save aG0aep6G/deee2872969fb07c2d98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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