what can cause Visual Studio to rebuild my entire solution all the time? - Stack Overflow: "You can use the configuration manager to set up a specific config for your sln that will only build the projects you specify. You can find it under Build->Configuration Manager"
This fixed it for me. Somehow one of the projects had become unchecked.
Wednesday, January 30, 2013
C# Threadsafe Random
/// A threadsafe wrapper around
public static class Randem {
private static int seed;
static Randem() { seed = Environment.TickCount; }
///
/// Provide to each thread its own
///
private static readonly ThreadLocal< Random > ThreadSafeRandom = new ThreadLocal< Random >( valueFactory: () => new Random( Interlocked.Increment( ref seed ) ), trackAllValues: false );
///
/// A thread-local
///
public static Random Instance { get { return ThreadSafeRandom.Value; } }
///
/// Returns a random float between
///
///
///
///
public static float NextFloat( float min = 0, float max = 1 ) { return ( float ) ( min + ( Instance.NextDouble() * ( max - min ) ) ); }
///
/// Generate a random number between
///
/// The inclusive lower bound of the random number returned.
/// The exclusive upper bound of the random number returned.
///
public static int Next( int minValue, int maxValue ) { return Instance.Next( minValue: minValue, maxValue: maxValue ); }
C# TakeLast()
///
/// Remove and return the last item in the list, otherwise return null.
///
///
///
///
public static TType TakeLast
if ( list == null ) {
throw new ArgumentNullException( "list" );
}
var index = list.Count - 1;
if ( index < 0 ) {
return default( TType );
}
var item = list[ index ];
list.RemoveAt( index );
return item;
}
C# List TakeFirst()
/// Remove and return the first item in the list, otherwise return null.
public static TType TakeFirst
if ( list == null ) {
throw new ArgumentNullException( "list" );
}
if ( list.Count <= 0 ) {
return default( TType );
}
var item = list[ 0 ];
list.RemoveAt( 0 );
return item;
}
C#/.NET Little Wonders: 5 Easy Ways to Combine Sequences
C#/.NET Little Wonders: 5 Easy Ways to Combine Sequences:
If you need to squeeze a little more performance to combine large lists or other enumerable sources, that does not contain any duplicate items, then here's what I've found in my testing:
Fastest, with no duplicates: Concat(list1).Concat(list2).Concat(list3).Concat(list4).Union(list5);
Remember, this style worked the best in my classes. Always test yours..
If you need to squeeze a little more performance to combine large lists or other enumerable sources, that does not contain any duplicate items, then here's what I've found in my testing:
Fastest, with no duplicates: Concat(list1).Concat(list2).Concat(list3).Concat(list4).Union(list5);
Remember, this style worked the best in my classes. Always test yours..
Saturday, January 26, 2013
Tuesday, January 15, 2013
Microsoft SQL Server 2012 TempDB Best Practices
Here are my performance guidelines I've gleaned from experience as a DBA and the researching on the internet:
- Move the primary TempDB.mdf to its own hard drive or the fastest drive in your system.
ALTER DATABASE [tempdb] MODIFY FILE (NAME = tempdev, FILENAME = 'T:\TempDB\Tempdb.mdf');
- Add additional tempdb_N.mdf, one per spindle per physical cpu core.
- On each tempdb.mdf, set the Autogrowth to 1% and unlimited.
- Some DBAs recommend setting autogrowth off and setting a maxium initial size to avoid fragmentation and 'pauses' on query executions. I disagree for the simple reason that in MSSQL 2012 tempdb makes good use of its internal bitmaps and will grow with the queries as needed. Never shrink the tempdb unless you need the space.
- Move the primary TempDB.ldf it its own hard drive or the fastest drive in your system.
ALTER DATABASE tempdb MODIFY FILE (NAME = templog, FILENAME = 'L:\TempDB\Tempdb.ldf');
- Restart the server and verify your database changes:
select [name], [physical_name] AS [CurrentLocation], [state_desc] from [sys].[master_files] order by [name]
- Defragment the free space on all drives. I recommend Defraggler or Auslogics Defrag.
Subscribe to:
Posts (Atom)