Skip to content

Commit

Permalink
perf(memory-leaks): introduce Tasks.Arrays.Length
Browse files Browse the repository at this point in the history
  • Loading branch information
LSViana committed Oct 16, 2023
1 parent 6b99ed4 commit f08401b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Tests/YDotNet.Tests.Driver/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

using YDotNet.Tests.Driver.Tasks.Arrays;

new Iterate().Run();
new Length().Run();
47 changes: 47 additions & 0 deletions Tests/YDotNet.Tests.Driver/Tasks/Arrays/Length.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using YDotNet.Document;
using YDotNet.Document.Cells;
using YDotNet.Tests.Driver.Abstractions;

namespace YDotNet.Tests.Driver.Tasks.Arrays;

public class Length : ITask
{
public Task Run()
{
var count = 0;

// Create many documents
while (count < 1_000_000)
{
// After 1s, stop and show the user the amount of documents
if (count > 0)
{
Console.WriteLine("Status Report");
Console.WriteLine($"\tArrays:\t{count}");
Console.WriteLine();
}

if (count % 1_000 == 0)
{
Thread.Sleep(millisecondsTimeout: 15);
}

// Create many documents
for (var i = 0; i < 100; i++)
{
var doc = new Doc();
var array = doc.Array($"sample-{i}");

var transaction = doc.WriteTransaction();
array.InsertRange(transaction, index: 0, new[] { Input.Long(value: 2469L) });
var _ = array.Length;
transaction.Commit();

doc.Dispose();
count++;
}
}

return Task.CompletedTask;
}
}

0 comments on commit f08401b

Please sign in to comment.