Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.stdio;
- import std.concurrency;
- import core.memory;
- import core.thread;
- version=ManyAllocations;
- version(ManyAllocations)
- alias ulong testtype;
- else
- alias uint testtype;
- void client() {
- for (bool running = true; running; ) {
- receive(
- (testtype a, testtype b, testtype c, testtype d) {
- },
- (OwnerTerminated t) {
- running = false;
- }
- );
- }
- }
- void main() {
- auto tid = spawn(&client);
- int allocations = 0;
- auto totalBeforeMem = GC.stats.usedSize;
- foreach (i; 0 .. 100) {
- Thread.sleep(usecs(100));
- auto beforeMem = GC.stats.usedSize;
- tid.send(cast(testtype) 1, cast(testtype) 2, cast(testtype) 3, cast(testtype) 4);
- auto afterMem = GC.stats.usedSize;
- if (afterMem > beforeMem)
- allocations++;
- }
- auto totalAfterMem = GC.stats.usedSize;
- writefln("allocations: %d bytes: %d", allocations, totalAfterMem - totalBeforeMem);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement