Beispiel #1
0
        public static List<payloadresult> PayloadQueuedFS(int threadcount, int iterations, int payloadsize, int filescount)
        {
            List<payloadresult> retval = new List<payloadresult>();

            var qfs = new QueuedFileSystem(5);

            byte[] testobject = new byte[payloadsize];
            MemoryStream teststream = new MemoryStream(testobject);

            //generate short list of filenames
            List<string> filenames = GenerateFilenames(filescount);

            //write all filenames
            for (int i = 0; i < filenames.Count; i++)
            {
                qfs.SaveStream(filenames[i], teststream);
                //QueuedFileSystem.SaveObject(filenames[i], testobject);
            }

            //check read speed
            var sw = TimePayload(threadcount, iterations , () =>
            {
                var stream = qfs.LoadStream(filenames[GetRandom(0, filenames.Count - 1)]);
            });

            retval.Add(new payloadresult
            {
                Method = "QFS2",
                Action = "R",
                Threads = threadcount,
                Time = sw.ElapsedMilliseconds
            });

            Console.WriteLine("Threads: {0} QueuedFS Load took {1}ms fps: {2}", threadcount, sw.ElapsedMilliseconds, ((threadcount * iterations) / ((sw.ElapsedMilliseconds) / 1000f)));

            //check write speed
            sw = TimePayload(threadcount, iterations, () =>
            {
                qfs.SaveStream(filenames[GetRandom(0, filenames.Count - 1)], teststream);
            });

            retval.Add(new payloadresult
            {
                Method = "QFS2",
                Action = "W",
                Threads = threadcount,
                Time = sw.ElapsedMilliseconds
            });

            Console.WriteLine("Threads: {0} QueuedFS Save took {1}ms fps: {2}", threadcount, sw.ElapsedMilliseconds, ((threadcount * iterations) / ((sw.ElapsedMilliseconds) / 1000f)));

            //check readwrite speed
            sw = TimePayload(threadcount, iterations / 2, () =>
            {
                var stream = qfs.LoadStream(filenames[GetRandom(0, filenames.Count - 1)]);
                qfs.SaveStream(filenames[GetRandom(0, filenames.Count - 1)], teststream);
            });

            retval.Add(new payloadresult
            {
                Method = "QFS2",
                Action = "R/W",
                Threads = threadcount,
                Time = sw.ElapsedMilliseconds
            });

            Console.WriteLine("Threads: {0} QueuedFS Save/Load took {1}ms fps:{2}", threadcount, sw.ElapsedMilliseconds, ((threadcount * iterations) / ((sw.ElapsedMilliseconds) / 1000f)));

            //cleanup
            DeleteFiles(filenames);

            qfs.Dispose();

            return retval;
        }
Beispiel #2
0
        public static List <payloadresult> PayloadQueuedFS(int threadcount, int iterations, int payloadsize, int filescount)
        {
            List <payloadresult> retval = new List <payloadresult>();

            var qfs = new QueuedFileSystem(5);

            byte[]       testobject = new byte[payloadsize];
            MemoryStream teststream = new MemoryStream(testobject);

            //generate short list of filenames
            List <string> filenames = GenerateFilenames(filescount);

            //write all filenames
            for (int i = 0; i < filenames.Count; i++)
            {
                qfs.SaveStream(filenames[i], teststream);
                //QueuedFileSystem.SaveObject(filenames[i], testobject);
            }

            //check read speed
            var sw = TimePayload(threadcount, iterations, () =>
            {
                var stream = qfs.LoadStream(filenames[GetRandom(0, filenames.Count - 1)]);
            });

            retval.Add(new payloadresult
            {
                Method  = "QFS2",
                Action  = "R",
                Threads = threadcount,
                Time    = sw.ElapsedMilliseconds
            });

            Console.WriteLine("Threads: {0} QueuedFS Load took {1}ms fps: {2}", threadcount, sw.ElapsedMilliseconds, ((threadcount * iterations) / ((sw.ElapsedMilliseconds) / 1000f)));

            //check write speed
            sw = TimePayload(threadcount, iterations, () =>
            {
                qfs.SaveStream(filenames[GetRandom(0, filenames.Count - 1)], teststream);
            });

            retval.Add(new payloadresult
            {
                Method  = "QFS2",
                Action  = "W",
                Threads = threadcount,
                Time    = sw.ElapsedMilliseconds
            });

            Console.WriteLine("Threads: {0} QueuedFS Save took {1}ms fps: {2}", threadcount, sw.ElapsedMilliseconds, ((threadcount * iterations) / ((sw.ElapsedMilliseconds) / 1000f)));

            //check readwrite speed
            sw = TimePayload(threadcount, iterations / 2, () =>
            {
                var stream = qfs.LoadStream(filenames[GetRandom(0, filenames.Count - 1)]);
                qfs.SaveStream(filenames[GetRandom(0, filenames.Count - 1)], teststream);
            });

            retval.Add(new payloadresult
            {
                Method  = "QFS2",
                Action  = "R/W",
                Threads = threadcount,
                Time    = sw.ElapsedMilliseconds
            });

            Console.WriteLine("Threads: {0} QueuedFS Save/Load took {1}ms fps:{2}", threadcount, sw.ElapsedMilliseconds, ((threadcount * iterations) / ((sw.ElapsedMilliseconds) / 1000f)));

            //cleanup
            DeleteFiles(filenames);

            qfs.Dispose();

            return(retval);
        }