Skip to content

Instantly share code, notes, and snippets.

@ChiiAyano
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChiiAyano/9865907 to your computer and use it in GitHub Desktop.
Save ChiiAyano/9865907 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
namespace ConsoleApplication3
{
class Program
{
private static string hoge;
private static string fuga;
static void Main(string[] args)
{
Test();
Console.ReadKey();
}
private async static void Test()
{
TestAsync2();
await TestAsync();
}
private async static Task TestAsync()
{
var startTime = DateTime.Now;
await Task.Factory.StartNew(() =>
{
for (int i = 0; i < 100000; i++)
{
hoge += "f";
}
});
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + " TestAsync Time: " + (DateTime.Now - startTime).TotalMilliseconds + "msec");
}
private async static void TestAsync2()
{
var startTime = DateTime.Now;
await Task.Factory.StartNew(() =>
{
for (int i = 0; i < 100000; i++)
{
fuga += "f";
}
});
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + " TestAsync2 Time: " + (DateTime.Now - startTime).TotalMilliseconds + "msec");
}
}
}
10:43:54.464 TestAsync2 Time: 2531.3014msec
10:43.54.464 TestAsync Time: 2515.6764msec
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
namespace ConsoleApplication3
{
class Program
{
private static string hoge;
private static string fuga;
static void Main(string[] args)
{
Test();
Console.ReadKey();
}
private async static void Test()
{
await TestAsync2();
await TestAsync();
}
private async static Task TestAsync()
{
var startTime = DateTime.Now;
await Task.Factory.StartNew(() =>
{
for (int i = 0; i < 100000; i++)
{
hoge += "f";
}
});
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + " TestAsync Time: " + (DateTime.Now - startTime).TotalMilliseconds + "msec");
}
private async static Task TestAsync2()
{
var startTime = DateTime.Now;
await Task.Factory.StartNew(() =>
{
for (int i = 0; i < 100000; i++)
{
fuga += "f";
}
});
Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + " TestAsync2 Time: " + (DateTime.Now - startTime).TotalMilliseconds + "msec");
}
}
}
10:42:26.737 TestAsync2 Time: 1421.8846msec
10:42.28.581 TestAsync Time: 1828.1737msec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment