Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string processFilePath = args[0];

            if (!File.Exists(processFilePath))
            {
                Console.WriteLine("File {0} does not exist.", processFilePath);
            }

            ProcessStartInfo processStartInfo = new ProcessStartInfo(args[0]);

            processStartInfo.Arguments = String.Join(" ", args.Skip(1));
            var  process              = Process.Start(processStartInfo);
            long maxNetMemory         = 0;
            long maxPrivateWorkingSet = 0;

            using (ManagedMemoryCounter counter = new ManagedMemoryCounter(process))
            {
                Stopwatch timer = Stopwatch.StartNew();
                timer.Start();

                while (!counter.HasProcessExited())
                {
                    var bytesInHeap = counter.BytesInAllHeaps / 1024;
                    maxNetMemory = Math.Max(maxNetMemory, bytesInHeap);

                    var privateWorkingSet = counter.PrivateWorkingSet / 1024;
                    maxPrivateWorkingSet = Math.Max(maxPrivateWorkingSet, privateWorkingSet);
                    Thread.Sleep(100);
                }

                timer.Stop();
                Console.WriteLine("{0},{1},{2}", timer.ElapsedMilliseconds, maxNetMemory, maxPrivateWorkingSet);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            string processFilePath = args[0];

            if (!File.Exists(processFilePath))
            {
                Console.WriteLine("File {0} does not exist.", processFilePath);
            }

            ProcessStartInfo processStartInfo = new ProcessStartInfo(args[0]);

            processStartInfo.Arguments = String.Join(" ", args.Skip(1));
            // processStartInfo.UseShellExecute = false;
            var process = Process.Start(processStartInfo);

            using (ManagedMemoryCounter counter = new ManagedMemoryCounter(process))
            {
                Stopwatch timer = Stopwatch.StartNew();
                timer.Start();

                while (!counter.HasProcessExited())
                {
                    var bytesInHeap = counter.BytesInAllHeaps;

                    Console.WriteLine(bytesInHeap);
                    Thread.Sleep(100);
                }

                timer.Stop();
                var seconds = timer.ElapsedMilliseconds / 1000;
                Console.WriteLine("Elapsed time: {0} seconds.", seconds);
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            string processFilePath = args[0];
            if (!File.Exists(processFilePath))
            {
                Console.WriteLine("File {0} does not exist.", processFilePath);
            }

            ProcessStartInfo processStartInfo = new ProcessStartInfo(args[0]);
            processStartInfo.Arguments = String.Join(" ", args.Skip(1)); 
            // processStartInfo.UseShellExecute = false;
            var process = Process.Start(processStartInfo);

            using (ManagedMemoryCounter counter = new ManagedMemoryCounter(process))
            {
                Stopwatch timer = Stopwatch.StartNew(); 
                timer.Start();

                while (!counter.HasProcessExited())
                {
                    var bytesInHeap = counter.BytesInAllHeaps;

                    Console.WriteLine(bytesInHeap);
                    Thread.Sleep(100);
                }

                timer.Stop();
                var seconds = timer.ElapsedMilliseconds / 1000;
                Console.WriteLine("Elapsed time: {0} seconds.", seconds);
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            string processFilePath = args[0];
            if (!File.Exists(processFilePath))
            {
                Console.WriteLine("File {0} does not exist.", processFilePath);
            }

            ProcessStartInfo processStartInfo = new ProcessStartInfo(args[0]);
            processStartInfo.Arguments = String.Join(" ", args.Skip(1)); 
            var process = Process.Start(processStartInfo);
            long maxNetMemory = 0;
            long maxPrivateWorkingSet = 0;

            using (ManagedMemoryCounter counter = new ManagedMemoryCounter(process))
            {
                Stopwatch timer = Stopwatch.StartNew(); 
                timer.Start();

                while (!counter.HasProcessExited())
                {
                    var bytesInHeap = counter.BytesInAllHeaps / 1024;
                    maxNetMemory = Math.Max(maxNetMemory, bytesInHeap);

                    var privateWorkingSet = counter.PrivateWorkingSet / 1024;
                    maxPrivateWorkingSet = Math.Max(maxPrivateWorkingSet, privateWorkingSet);
                    Thread.Sleep(100);
                }

                timer.Stop();
                Console.WriteLine("{0},{1},{2}", timer.ElapsedMilliseconds, maxNetMemory, maxPrivateWorkingSet);
            }
        }