本文整理汇总了C#中Stopwatch.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# Stopwatch.Reset方法的具体用法?C# Stopwatch.Reset怎么用?C# Stopwatch.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stopwatch
的用法示例。
在下文中一共展示了Stopwatch.Reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
if (SVGFile != null) {
Stopwatch w = new Stopwatch();
w.Reset();
w.Start();
ISVGDevice device;
if(useFastButBloatedRenderer)
device = new SVGDeviceFast();
else
device = new SVGDeviceSmall();
m_implement = new Implement(this.SVGFile, device);
w.Stop();
long c = w.ElapsedMilliseconds;
w.Reset();
w.Start();
m_implement.StartProcess();
w.Stop();
long p = w.ElapsedMilliseconds;
w.Reset();
w.Start();
renderer.material.mainTexture = m_implement.GetTexture();
w.Stop();
long r = w.ElapsedMilliseconds;
UnityEngine.Debug.Log("Construction: " + Format(c) + ", Processing: " + Format(p) + ", Rendering: " + Format(r));
Vector2 ts = renderer.material.mainTextureScale;
ts.x *= -1;
renderer.material.mainTextureScale = ts;
renderer.material.mainTexture.filterMode = FilterMode.Trilinear;
}
}
示例2: Main
public static void Main(string[] args)
{
Stopwatch sw = new Stopwatch();
int status;
// Generate input data
sw.Start();
const int SIZE = 384;
List<int> firstVector = new List<int>();
List<int> secondVector = new List<int>();
const int Scalar = 3;
Random random = new Random();
for (int i = 0; i < SIZE; i++)
{
firstVector.Add(random.Next(0, 100));
secondVector.Add(random.Next(0, 100));
}
sw.Stop();
Console.WriteLine("Generating input data:\t\t\t\t{0}s", sw.Elapsed.TotalMilliseconds / 1000);
// DFE Output
sw.Reset();
sw.Start();
List<int> dataOutDFE = VectorAdditionDfe(SIZE, firstVector, secondVector, Scalar);
sw.Stop();
Console.WriteLine("DFE vector addition total time:\t\t\t{0}s", sw.Elapsed.TotalMilliseconds / 1000);
// CPU Output
sw.Reset();
sw.Start();
List<int> dataOutCPU = VectorAdditionCpu(SIZE, firstVector, secondVector, Scalar);
sw.Stop();
Console.WriteLine("CPU vector addition time:\t\t\t{0}s", sw.Elapsed.TotalMilliseconds / 1000);
// Checking results
sw.Reset();
sw.Start();
status = Check(dataOutDFE, dataOutCPU, SIZE);
sw.Stop();
Console.WriteLine("Checking results:\t\t\t\t{0}s", sw.Elapsed.TotalMilliseconds / 1000);
if (status > 0)
{
Console.WriteLine("Test failed {0} times! ", status);
Environment.Exit(-1);
}
else
{
Console.WriteLine("Test passed!");
}
}
示例3: Main
/// <summary> Calculates simpleDfe and simpleCpu and
/// checks if they return the same value.
/// </summary>
/// <param name = "args"> Command line arguments </param>
public static void Main(string[] args)
{
Stopwatch sw = new Stopwatch();
int status;
sw.Start();
const int SIZE = 1024;
List<double> dataIn = new List<double>();
for (int i = 0; i < SIZE; i++)
{
dataIn.Add(i + 1);
}
sw.Stop();
Console.WriteLine("Generating input data:\t\t\t\t{0}s", sw.Elapsed.TotalMilliseconds / 1000);
// DFE Output
sw.Reset();
sw.Start();
List<double> dataOutDFE = SimpleDFE(SIZE, dataIn);
sw.Stop();
Console.WriteLine("DFE simple total time:\t\t\t\t{0}s", sw.Elapsed.TotalMilliseconds / 1000);
// CPU Output
sw.Reset();
sw.Start();
List<double> dataOutCPU = SimpleCPU(SIZE, dataIn);
sw.Stop();
Console.WriteLine("CPU simple total time:\t\t\t\t{0}s", sw.Elapsed.TotalMilliseconds / 1000);
// Checking results
sw.Reset();
sw.Start();
status = Check(dataOutDFE, dataOutCPU, SIZE);
sw.Stop();
Console.WriteLine("Checking results:\t\t\t\t{0}s", sw.Elapsed.TotalMilliseconds / 1000);
if (status > 0)
{
Console.WriteLine("Test failed {0} times! ", status);
Environment.Exit(-1);
}
else
{
Console.WriteLine("Test passed!");
}
}
示例4: Start
void Start()
{
Stopwatch timer = new Stopwatch();
timer.Start();
worldTree = new WorldTree(8);
//worldTree.ExpandNode(3);
TestWTI2(30);
timer.Stop();
// DumpToFile("WorldTreeDump2.txt");
DebugOutput.Shout("timer says: " + timer.ElapsedMilliseconds.ToString());
DebugOutput.Shout("there is " + worldTree.GetIndiceCount().ToString() + " nodes");
timer.Reset();
timer.Start();
TestWTI2(10);
//DumpToFile("WorldTreeDump.txt");
//TestWTI2();
//TestWTI(new Vector3(14, 14,14));
timer.Stop();
wti = new WorldTreeInterface(worldTree, transform.position);
DebugOutput.Shout("timer says: " + timer.ElapsedMilliseconds.ToString());
DebugOutput.Shout("there is " + worldTree.GetIndiceCount().ToString() + " nodes");
DumpToFile("WorldTreeDump.txt");
wti.DumpAllToFile("WTIDump.txt");
}
示例5: Main
static void Main()
{
Database db = new Database();
using (db)
{
var employees = db.Employees;
Stopwatch sw = new Stopwatch();
Console.WriteLine("EmployeeName | EmployeeDepartment | EmployeeTown");
sw.Start();
foreach (var item in employees)
{
Console.WriteLine("{0} | {1} | {2}", item.FirstName, item.Department.Name, item.Address.Town.Name);
}
sw.Stop();
Console.WriteLine();
Console.WriteLine("Time with problem N+1: {0}", sw.Elapsed);
Console.WriteLine("338 queryes with proffiler");
Console.WriteLine("------------------------------------------------------------");
sw.Reset();
sw.Start();
foreach (var item in employees.Include("Department").Include("Address.Town"))
{
Console.WriteLine("{0} | {1} | {2}", item.FirstName, item.Department.Name, item.Address.Town.Name);
}
sw.Stop();
Console.WriteLine("Time withouth problem N+1: {0}", sw.Elapsed);
Console.WriteLine("1 queryes with proffiler");
}
}
示例6: Main
public static void Main()
{
Stopwatch watch = new Stopwatch();
Random rand = new Random();
watch.Start();
for (int i = 0; i < iterations; i++)
DayOfYear1(rand.Next(1, 13), rand.Next(1, 29));
watch.Stop();
Console.WriteLine("Local array: " + watch.Elapsed);
watch.Reset();
watch.Start();
for (int i = 0; i < iterations; i++)
DayOfYear2(rand.Next(1, 13), rand.Next(1, 29));
watch.Stop();
Console.WriteLine("Static array: " + watch.Elapsed);
// trying to modify static int []
daysCumulativeDays[0] = 18;
foreach (int days in daysCumulativeDays)
{
Console.Write("{0}, ", days);
}
Console.WriteLine("");
// MY_STR_CONST = "NOT CONST";
}
示例7: Main
static void Main()
{
var list = new List<int>();
list.AddRange(Enumerable.Range(1, short.MaxValue/2));
var watch = new Stopwatch();
watch.Start();
var result1 = Method1(list);
watch.Stop();
Console.WriteLine("Elapsed Ticks for Method1: {0}, with result: {1}", watch.ElapsedTicks, result1);
var watch1Ticks = watch.ElapsedTicks;
watch.Reset();
watch.Start();
var result2 = Method2(list);
watch.Stop();
Console.WriteLine("Elapsed Ticks for Method2: {0}, with result: {1}", watch.ElapsedTicks, result2);
var watch2Ticks = watch.ElapsedTicks;
double result = (double) watch1Ticks / watch2Ticks - 1.0;
Console.WriteLine("Method2 is faster that Method1 in {0:P}", result);
Console.ReadKey();
}
示例8: MesureFloatOperationsPerformance
//Float operations
public static TimeSpan MesureFloatOperationsPerformance(float num, string operation, Stopwatch stopwatch)
{
stopwatch.Reset();
switch (operation)
{
case "square root":
{
stopwatch.Start();
Math.Sqrt(num);
stopwatch.Stop();
return stopwatch.Elapsed;
}
case "natural logarithm":
{
stopwatch.Start();
Math.Log(num);
stopwatch.Stop();
return stopwatch.Elapsed;
}
case "sinus":
{
stopwatch.Start();
Math.Sin(num);
stopwatch.Stop();
return stopwatch.Elapsed;
}
default:
throw new ArgumentException("Invalid operations");
}
}
示例9: TestCanUpdateCustomer
public void TestCanUpdateCustomer()
{
JsonServiceClient client = new JsonServiceClient("http://localhost:2337/");
//Force cache
client.Get(new GetCustomer { Id = 1 });
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
var cachedResponse = client.Get(new GetCustomer { Id = 1 });
stopwatch.Stop();
var cachedTime = stopwatch.ElapsedTicks;
stopwatch.Reset();
client.Put(new UpdateCustomer { Id = 1, Name = "Johno" });
stopwatch.Start();
var nonCachedResponse = client.Get(new GetCustomer { Id = 1 });
stopwatch.Stop();
var nonCacheTime = stopwatch.ElapsedTicks;
Assert.That(cachedResponse.Result, Is.Not.Null);
Assert.That(cachedResponse.Result.Orders.Count, Is.EqualTo(5));
Assert.That(nonCachedResponse.Result, Is.Not.Null);
Assert.That(nonCachedResponse.Result.Orders.Count, Is.EqualTo(5));
Assert.That(nonCachedResponse.Result.Name, Is.EqualTo("Johno"));
Assert.That(cachedTime, Is.LessThan(nonCacheTime));
}
示例10: Main
private static void Main()
{
Stopwatch timer = new Stopwatch();
timer.Start();
Console.WriteLine("Creating products data.....");
OrderedMultiDictionary<double, string> products = GenerateProducts();
timer.Stop();
Console.WriteLine("Time needed: "+timer.Elapsed);
timer.Reset();
double lowestPrice = randomNumberGenerator.NextDouble() * (MaxPrice/2 - MinPrice) + MinPrice;
double highestPrice = randomNumberGenerator.NextDouble() * (MaxPrice - lowestPrice) + lowestPrice;
bool isFirstSearch = true;
timer.Start();
for (int i = 0; i < CountSearches; i++)
{
IEnumerable<KeyValuePair<double, ICollection<string>>> extract = products.Range(lowestPrice, true, highestPrice, true).Take(CountResults);
if (isFirstSearch)
{
timer.Stop();
Console.WriteLine("First search result");
Console.WriteLine("Price range from {0:F2} to {1:F2}:", lowestPrice, highestPrice);
PrintSearchResults(extract);
isFirstSearch = false;
Console.WriteLine("Time needed: {0}\n {1} more to go......", timer.Elapsed, CountSearches - 1);
timer.Start();
}
}
timer.Stop();
Console.WriteLine("Total search time: "+timer.Elapsed);
}
示例11: KinectPlayer
public KinectPlayer(Vector3 platformData)
{
JumpLeft = false;
progressBarBackground = new Sprite();
progressBarBackground.Rectangle = new Rectangle(0,0,GameConstants.HorizontalGameResolution,GameConstants.VerticalGameResolution/80);
progressBarFrame = new Sprite();
progressBarFrame.Rectangle = new Rectangle(0,0,GameConstants.HorizontalGameResolution,GameConstants.VerticalGameResolution/80);
newGameCounter = new Stopwatch();
newGameCounter.Reset();
nyanSprite = new Sprite();
nyanSprite.Rectangle = new Rectangle(-(int)GameConstants.nyanDimensions.X, (int)GameConstants.VerticalGameResolution/25, (int)GameConstants.nyanDimensions.X, (int)GameConstants.nyanDimensions.Y);
progressBarRectangle=new Rectangle(0,0,GameConstants.HorizontalGameResolution,GameConstants.VerticalGameResolution/80);
progressBarTextures = new Texture2D[3];
modelPosition = new Hero(new ObjectData3D
{
Scale = new Vector3(GameConstants.HeroScale),
Rotation = new Vector3(0.0f)
});
currentStance = GameConstants.PlayerStance.GameSettingsSetup;
lastStance = GameConstants.PlayerStance.GameSettingsSetup;
isMotionCheckEnabled = true;
modelGroundLevel = platformData.Y+GameConstants.PlayerModelHeight;
modelPosition.objectArrangement.Position = new Vector3(platformData.X,modelGroundLevel,platformData.Z);
modelPosition.oldArrangement = modelPosition.objectArrangement;
currentModel = modelUp;
}
示例12: Start
// Use this for initialization
void Start()
{
file = new System.IO.StreamWriter("K:\\Logs\\ArrayTest.txt");
array1 = new GameObject[cycles];
array2 = new GameObject[cycles];
stopWatch = new Stopwatch();
GameObject test = Instantiate(memCell, Vector3.zero, Quaternion.identity) as GameObject;
for (int i = 0; i< cycles; i++){
array1[i] = Instantiate(memCell, new Vector3(i,0f,0f), Quaternion.identity) as GameObject;
array1[i].SetActive(false);
}
for (int i=0; i<cycles; i++){
stopWatch.Reset ();
stopWatch.Start();
//write(array1[i], i);
write(i);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
file.WriteLine(ts.TotalMilliseconds + "\t");
}
}
示例13: playGame
public static void playGame(Game.Client client)
{
GameInit gameInit = client.ready();
GameInfo gameInfo = gameInit.GameInfo;
Solution solution = new Solution(gameInit);
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
while (true) {
stopwatch.Stop();
synchronize(gameInfo.NextWorldModelTimeEstimateMs - stopwatch.Elapsed.Milliseconds);
gameInfo = client.getGameInfo();
stopwatch.Reset();
stopwatch.Start ();
if (gameInfo.GameStatus == GameStatus.FINISHED)
{
solution.EndOfGame(gameInfo.GameResult);
break;
}
if (gameInfo.IsMyTurn)
{
Command command = solution.playTurn(gameInfo.WorldModel, gameInfo.Cycle);
client.sendCommand(command);
}
}
}
示例14: Civilian
public Civilian(Vector2 origin, Texture2D texture)
: base(origin, texture)
{
lifeTime = new Stopwatch();
lifeTime.Reset();
this.Heading = new Vector2(0, 1);
shot = false;
}
示例15: Should_be_fast
public void Should_be_fast()
{
var stopWatch = new Stopwatch();
stopWatch.Start();
for (var i = 0; i < 10000; i++)
SaveFocusSession(i.ToString());
Assert.That(stopWatch.Elapsed.TotalSeconds, Is.LessThan(10));
stopWatch.Reset();
var allSessions = LoadAllSessions.Run();
Assert.That(stopWatch.Elapsed.Milliseconds, Is.LessThan(300));
Assert.That(allSessions.Count, Is.EqualTo(10000));
stopWatch.Reset();
Console.WriteLine(allSessions.Sum(x => x.Minutes));
Console.WriteLine(stopWatch.Elapsed);
}