All pastes #545805 Raw Edit

Stuff

public text v1 · immutable
·published 2007-06-06 21:32 UTC
rendered paste body
/*
 *
 *	User: jarek
 * 	Date: 2007-06-06
 * 	Time: 23:00
 * 	Version: 0.1
 * 
 * --------------------------------------------------------------------------------
 * Date			Version		User		Change
 * --------------------------------------------------------------------------------
 *
 */
using System;
using System.Collections.Generic;

namespace sharpalloc
{	
	class small
	{
		private readonly byte[] data = new byte[16];
	}
	
	class medium
	{
		private readonly byte[] data = new byte[256];
	}
	
	class large
	{
		private readonly byte[] data = new byte[1024];
	}
	
	class mess
	{
		private small[] samlcol;
		private large[] largecol;
		private medium[] medcol;
		
		private readonly int n = 100000;
		
		public mess()
		{
			this.samlcol = new small[this.n];
			this.largecol = new large[this.n];
			this.medcol = new medium[this.n];
		}
		
		public void messup()
		{
			for(int i = 0; i < this.n; i++) {
				this.samlcol[i] = new small();
				this.medcol[i] = new medium();
			}
			this.medcol = null;
		}
		
		public void fuckup()
		{
			for(int i = 0; i < this.n; i++) {
				this.largecol[i] = new large();
			}
		}
	}
	
	class MainClass
	{		

		public static void Main(string[] args)
		{
			
			mess m = new mess();
			Console.WriteLine("Press ENTER to start...");
			Console.ReadLine();
			int startcount = Environment.TickCount;
			m.messup();
			m.fuckup();
			int endcount = Environment.TickCount;
			int result = endcount - startcount;
			Console.WriteLine("Result ticks: " + result.ToString());
			Console.ReadLine();
		}
	}
}