Last active
August 29, 2015 13:57
-
-
Save ChiiAyano/9865907 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10:43:54.464 TestAsync2 Time: 2531.3014msec | |
10:43.54.464 TestAsync Time: 2515.6764msec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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