public void CompareBuildingSpeeds()
		{
			m_custTable= new DataTable("Customers");
			// add columns
			m_custTable.Columns.Add( "id", typeof(int) );
			m_custTable.Columns.Add( "name", typeof(string) );
			m_custTable.Columns.Add( "address", typeof(string) );
			m_custTable.Columns.Add( "min", typeof(int) );
			m_custTable.Columns["min"].DefaultValue = 0;
			m_custTable.Columns.Add( "max", typeof(int) );
			m_custTable.Columns.Add( "Client name", typeof(string) );
			m_custTable.Columns.Add( "Type of software", typeof(string) );
			
			//m_custTable.Columns[ "id" ].Unique = true;
			//m_custTable.PrimaryKey = new DataColumn[] { m_custTable.Columns["id"] };
			
			//m_custTable.ColumnChanging += new DataColumnChangeEventHandler(custTable_ColumnChanging);
			//m_custTable.RowChanging += new DataRowChangeEventHandler(custTable_RowChanging);
			
			int maxRows = 1000000;
			using (IPerformanceCounter counter = new PerformanceCounter())
			{
				
				AddRows(0, maxRows);
				Console.WriteLine(string.Format(
					"Added {0} number of rows to datatable in {1} milisec",
					maxRows,
					counter.GetMilisec()));
			}
			
			List<object[]> objects = new List<object[]>();
			using (IPerformanceCounter counter = new PerformanceCounter())
			{
				for( int id = 0; id <= maxRows; id++ )
				{
					int valMin = rnd.Next(Int32.MinValue, Int32.MaxValue);
					objects.Add(
						new object[] { id,
							string.Format("customer{0}", id),
							string.Format("address{0}", id ),
							valMin,
							valMin + rnd.Next(1, 1000),
							customerNames[rnd.Next(0, customerNames.Length)],
							typesOfSoftware[rnd.Next(0, typesOfSoftware.Length)]
						} );
				}
				Console.WriteLine(string.Format(
					"Added {0} number of rows to list<object[]> in {1} milisec",
					maxRows,
					counter.GetMilisec()));
			}
		}
		public void GetRowsIndex_Performance()
		{
			// this test, sadly, tests nothing
			// remove it
			RangeRegion region = new RangeRegion(new Range(0, 0, 10000, 5000));
			
			using (IPerformanceCounter counter = new PerformanceCounter())
			{
				region.GetRowsIndex();
				Console.WriteLine(string.Format(
					"Test executed in {0} ms", counter.GetMilisec()));
			}
		}
Пример #3
0
		public List<Range> GetRanges(RangeCreator ranges)
		{
			List<Range> results = new List<Range>();
			for (var col = 0; col < ranges.ColCount; col++)
				for (var row = 0; row < ranges.RowCount; row++)
			{
				Range? index;
				IPerformanceCounter counter = null;
				using (counter = new PerformanceCounter())
				{
					index = ranges.SpannedRangesList.GetFirstIntersectedRange(new Position(row, col));
				}
				TotalQueries ++;
				TotalTimeSpent += counter.GetMilisec();
				if (index != null)
					results.Add(index.Value);
			}
			AverageTimeSpent = TotalTimeSpent / TotalQueries;
			return results;
		}
Пример #4
0
		public List<Range> GetRanges(QuadTree tree)
		{
			List<Range> results = new List<Range>();
			
			for (var col = 0; col < tree.Bounds.ColumnsCount; col++)
				for (var row = 0; row < tree.Bounds.RowsCount; row++)
			{
				List<Range> ranges = null;
				IPerformanceCounter counter = null;
				using (counter = new PerformanceCounter())
				{
					ranges = tree.Query(new Position(row, col));
					
				}
				TotalQueries ++;
				TotalTimeSpent += counter.GetMilisec();
				results.AddRange(ranges);
			}
			AverageTimeSpent = TotalTimeSpent / TotalQueries;
			return results;
		}
		public void SpannedCellCreation_Performance()
		{
			// originaly this test run in ~11900 ms
			// after implementing this takes 1350ms :)
			var grid = new Grid();
			var count = 10000;
			var columns = 500;
			grid.Redim(count, columns);
			
			
			using (var counter = new PerformanceCounter())
			{
				for (int i = 0; i < count; i++)
				{
					grid[i, 0] = new Cell();
					grid[i, 0].SetSpan(50, 500);
					
					i+=50;
				}
				Console.WriteLine("Test finished in {0} ms", counter.GetMilisec());
			}
		}
		public void GetSelectionRegion_GetRows_Index_Performance()
		{
			// select range:
			// * from row 1 to 2000
			// Print out how long in seconds that function takes to execute
			
			// The tests take seconds to execute
			// 6 seconds, 2008-12-11, AMD Athlon 64 X2 dual machine
			// 0 seconds, 2008-12-11, AMD Athlon 64 X2 dual machine
			
			Grid grid = new TestRowSelectionHelper().CreateGridWithRows(2000);

			grid.Selection.SelectRange(new Range(0, 0, 1999, 1), true);
			
			using (IPerformanceCounter counter = new PerformanceCounter())
			{
				grid.Selection.GetSelectionRegion().GetRowsIndex();
				
				Console.WriteLine(string.Format(
					"Test executed in {0} seconds", counter.GetSeconds()));
			}
		}
Пример #7
0
		private void btLoad_Click(object sender, System.EventArgs e)
		{
			using (var counter = new PerformanceCounter())
			{
				grid.Redim(0, 0);
				//Visual properties shared between all the cells
				SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
				view.BackColor = Color.Snow;

				//Editor (IDataModel) shared between all the cells
				SourceGrid.Cells.Editors.TextBox editor = new
					SourceGrid.Cells.Editors.TextBox(typeof(string));

				grid.Redim(int.Parse(txtRows.Text), int.Parse(txtCols.Text));

				if (chkAddHeaders.Checked && grid.RowsCount > 0 &&
				    grid.ColumnsCount > 0)
				{
					grid.FixedRows = 1;
					grid.FixedColumns = 1;

					for (int r = grid.FixedRows; r < grid.RowsCount; r++)
						grid[r, 0] = new SourceGrid.Cells.RowHeader(r);

					for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++)
					{
						SourceGrid.Cells.ColumnHeader header = new
							SourceGrid.Cells.ColumnHeader(c);
						header.AutomaticSortEnabled = false;
						grid[0, c] = header;
					}
					grid[0, 0] = new SourceGrid.Cells.Header();
				}
				else
				{
					grid.FixedRows = 0;
					grid.FixedColumns = 0;
				}

				for (int r = grid.FixedRows; r < grid.RowsCount; r++)
					for (int c = grid.FixedColumns; c < grid.ColumnsCount; c++)
				{
					grid[r, c] = new SourceGrid.Cells.Cell(r.ToString() + "," +
					                                       c.ToString());
					grid[r, c].Editor = editor;
					grid[r, c].View = view;
					var span = 3;
					if (chkAddColspan.Checked && (c + span < grid.ColumnsCount))
					{
						if (r % 2 == 0)
						{
							grid[r, c].ColumnSpan = span;
							c += span;
						}
					}
				}
				grid.Selection.Focus(new SourceGrid.Position(0, 0), true);
				this.toolStripStatusLabelBuildTime.Text = string.Format(
					"Rows added in {0} ms", counter.GetMilisec());
			}
		}
Пример #8
0
		private void CreateData()
		{
			this.toolStripProgressBar1.Maximum = m_numberOfrows;
			
			using (var counter = new PerformanceCounter())
			{
				dataGrid.SuspendLayout();
				for( int id = 101; id <= m_numberOfrows; id++ )
				{
					if (closing == true)
						return;
					AddRow(id);
					if (id % 15000 == 0)
					{
						this.toolStripProgressBar1.Value = id;
						//dataGrid.ResumeLayout();
						dataGrid.RecalcCustomScrollBars();
						UpdateTotalRowCount(counter);
						//dataGrid.SuspendLayout();
					}
					
					if (id % 100000 == 0)
					{
						dataGrid.ResumeLayout();
						//dataGrid.Refresh();
						dataGrid.SuspendLayout();
					}
				}
				//m_custTable.EndLoadData();
				dataGrid.ResumeLayout();
				dataGrid.RecalcCustomScrollBars();
				
				this.toolStripProgressBar1.Visible = false;
				UpdateTotalRowCount(counter);
				// enable sorting
				dataGrid.DataSource.AllowSort = true;
			}
		}