public static List<payloadresult> PayloadQueued(int threadcount, int iterations, int payloadsize, int filescount) { List<payloadresult> retval = new List<payloadresult>(); byte[] testobject = new byte[payloadsize]; MemoryStream teststream = new MemoryStream(testobject); QueuedStreamFileSystem qsf = new QueuedStreamFileSystem(5); //generate short list of filenames List<string> filenames = GenerateFilenames(filescount); //write all filenames for (int i = 0; i < filenames.Count; i++) { qsf.SaveStream(filenames[i], teststream); //QueuedFileSystem.SaveObject(filenames[i], testobject); } //check read speed var sw = TimePayload(threadcount, iterations , () => { var stream = qsf.LoadStream(filenames[GetRandom(0, filenames.Count - 1)]); }); retval.Add(new payloadresult { Method = "QFS1", Action = "R", Threads = threadcount, Time = sw.ElapsedMilliseconds }); Console.WriteLine("Threads: {0} Queued Load took {1}ms fps: {2}", threadcount, sw.ElapsedMilliseconds, ((threadcount * iterations) / ((sw.ElapsedMilliseconds) / 1000f))); //check write speed sw = TimePayload(threadcount, iterations , () => { qsf.SaveStream(filenames[GetRandom(0, filenames.Count - 1)], teststream); }); retval.Add(new payloadresult { Method = "QFS1", Action = "W", Threads = threadcount, Time = sw.ElapsedMilliseconds }); Console.WriteLine("Threads: {0} Queued Save took {1}ms fps: {2}", threadcount, sw.ElapsedMilliseconds, ((threadcount * iterations) / ((sw.ElapsedMilliseconds) / 1000f))); //check readwrite speed sw = TimePayload(threadcount, iterations / 2, () => { var stream = qsf.LoadStream(filenames[GetRandom(0, filenames.Count - 1)]); qsf.SaveStream(filenames[GetRandom(0, filenames.Count - 1)], teststream); }); retval.Add(new payloadresult { Method = "QFS1", Action = "R/W", Threads = threadcount, Time = sw.ElapsedMilliseconds }); Console.WriteLine("Threads: {0} Queued Save/Load took {1}ms fps:{2}", threadcount, sw.ElapsedMilliseconds, ((threadcount * iterations) / ((sw.ElapsedMilliseconds) / 1000f))); //cleanup DeleteFiles(filenames); qsf.Dispose(); return retval; }
public static List <payloadresult> PayloadQueued(int threadcount, int iterations, int payloadsize, int filescount) { List <payloadresult> retval = new List <payloadresult>(); byte[] testobject = new byte[payloadsize]; MemoryStream teststream = new MemoryStream(testobject); QueuedStreamFileSystem qsf = new QueuedStreamFileSystem(5); //generate short list of filenames List <string> filenames = GenerateFilenames(filescount); //write all filenames for (int i = 0; i < filenames.Count; i++) { qsf.SaveStream(filenames[i], teststream); //QueuedFileSystem.SaveObject(filenames[i], testobject); } //check read speed var sw = TimePayload(threadcount, iterations, () => { var stream = qsf.LoadStream(filenames[GetRandom(0, filenames.Count - 1)]); }); retval.Add(new payloadresult { Method = "QFS1", Action = "R", Threads = threadcount, Time = sw.ElapsedMilliseconds }); Console.WriteLine("Threads: {0} Queued Load took {1}ms fps: {2}", threadcount, sw.ElapsedMilliseconds, ((threadcount * iterations) / ((sw.ElapsedMilliseconds) / 1000f))); //check write speed sw = TimePayload(threadcount, iterations, () => { qsf.SaveStream(filenames[GetRandom(0, filenames.Count - 1)], teststream); }); retval.Add(new payloadresult { Method = "QFS1", Action = "W", Threads = threadcount, Time = sw.ElapsedMilliseconds }); Console.WriteLine("Threads: {0} Queued Save took {1}ms fps: {2}", threadcount, sw.ElapsedMilliseconds, ((threadcount * iterations) / ((sw.ElapsedMilliseconds) / 1000f))); //check readwrite speed sw = TimePayload(threadcount, iterations / 2, () => { var stream = qsf.LoadStream(filenames[GetRandom(0, filenames.Count - 1)]); qsf.SaveStream(filenames[GetRandom(0, filenames.Count - 1)], teststream); }); retval.Add(new payloadresult { Method = "QFS1", Action = "R/W", Threads = threadcount, Time = sw.ElapsedMilliseconds }); Console.WriteLine("Threads: {0} Queued Save/Load took {1}ms fps:{2}", threadcount, sw.ElapsedMilliseconds, ((threadcount * iterations) / ((sw.ElapsedMilliseconds) / 1000f))); //cleanup DeleteFiles(filenames); qsf.Dispose(); return(retval); }