Nuclex.Support/Documents/Nuclex.Support.txt
Markus Ewald db8c93eabd All cloners are now able to clone objects without default constructors; began work on a property-based expression tree cloner
git-svn-id: file:///srv/devel/repo-conversion/nusu@243 d2e56fa2-650e-0410-a79f-9358c0239efd
2012-02-08 15:20:39 +00:00

35 lines
1021 B
Plaintext

#if DEBUG
/// <summary>Generates a new random shuffle table</summary>
/// <param name="iterationCount">
/// Number of iterations in which to randomize the shuffle table
/// </param>
/// <returns>The new random shuffle table</returns>
public static byte[] generateShuffleTable(int iterationCount) {
byte[] shuffleTable = new byte[128];
for(int index = 0; index < 128; ++index)
shuffleTable[index] = index;
Random rng = new Random();
for(int iteration = 0; iteration < iterationCount; ++iteration) {
int firstIndex = rng.Next() % 128;
int secondIndex = rng.Next() % 128;
byte temp = shuffleTable[firstIndex];
shuffleTable[firstIndex] = shuffleTable[secondIndex];
shuffleTable[secondIndex] = temp;
}
return shuffleTable;
}
#endif
Benchmark of cloners:
SerializationCloner took 13424 ms
ReflectionCloner took 2126 ms
ExpressionTreeCloner took 171 ms