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.Threading.Tasks; | |
using Microsoft.AspNetCore; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Extensions.DependencyInjection; | |
namespace WebApplication1 | |
{ |
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
async function getUserProfile(userId) { | |
let [user, groups] = await Promise.all([ | |
db.getUser(userId), | |
db.getUserGroups(userId) | |
]); | |
return {userId, user, groups}; | |
} |
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.Concurrent; | |
using System.Linq; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace Common.Async | |
{ | |
public class LimitedLengthActionPool : IDisposable | |
{ |
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.Threading; | |
using System.Threading.Tasks; | |
namespace TestApp | |
{ | |
public class ParallelWhile |
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 (var dbContext = new MainDbContext()) | |
{ | |
for (var i = 0; i < 100000; i++) | |
{ | |
dbContext.Logs.Add(new Log() | |
{ | |
Key = Guid.NewGuid().ToString("D"), | |
Data = "some random data:" + Guid.NewGuid().ToString("D"), | |
UpdatedDate = DateTime.UtcNow | |
}); |
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
for (var i = 0; i < 100000; i++) | |
{ | |
using (var dbContext = new MainDbContext()) | |
{ | |
dbContext.Logs.Add(new Log() | |
{ | |
Key = Guid.NewGuid().ToString("D"), | |
Data = "some random data:" + Guid.NewGuid().ToString("D"), | |
UpdatedDate = DateTime.UtcNow | |
}); |
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 (var dbContext = new MainDbContext()) | |
{ | |
for (var i = 0; i < 100000; i++) | |
{ | |
dbContext.Database.ExecuteSqlCommand( | |
@"INSERT INTO [dbo].[Log] ([Key], [Data], [UpdatedDate]) | |
VALUES ( | |
convert(nchar(36), NEWID()), | |
'Some random data:' + convert(nchar(36), NEWID()), | |
GETDATE())"); |
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
db.system.js.save({ | |
_id: "test", | |
value: function () { | |
var start = new Date(); | |
for (var i = 1; i <= 100000; i++) { | |
db.getCollection('log').insert({ | |
"key": (new ObjectId()).toString(), | |
"data": "some random data: " + (new ObjectId()).toString(), | |
"updated_date": new Date() | |
}) |
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
var start = new Date(); | |
for (var i = 1; i <= 100000; i++) { | |
db.getCollection('log').insert({ | |
"key": (new ObjectId()).toString(), | |
"data": "some random data: " + (new ObjectId()).toString(), | |
"updated_date": new Date() | |
}) | |
} | |
print(new Date() - start); |
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
declare @i int | |
set @i = 1 | |
while @i <= 100000 | |
begin | |
INSERT INTO [dbo].[Log] ([Key], [Data], [UpdatedDate]) | |
VALUES | |
(convert(nchar(36), NEWID()), | |
'Some random data:' + convert(nchar(36), NEWID()), | |
GETDATE()) |