-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from LSViana/34-investigate-possible-memory-le…
…aks-part-1 Investigate possible memory leaks (part 1)
- Loading branch information
Showing
56 changed files
with
1,741 additions
and
88 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ on: | |
push: | ||
branches: | ||
- 'main' | ||
- '34-investigate-possible-memory-leaks' | ||
|
||
jobs: | ||
test: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace YDotNet.Tests.Driver.Abstractions; | ||
|
||
public interface ITask | ||
{ | ||
Task Run(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
|
||
using YDotNet.Tests.Driver.Tasks.Docs; | ||
|
||
new ObserveSubDocs().Run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using YDotNet.Document; | ||
using YDotNet.Tests.Driver.Abstractions; | ||
|
||
namespace YDotNet.Tests.Driver.Tasks.Arrays; | ||
|
||
public class Create : 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(); | ||
doc.Array($"sample-{i}"); | ||
doc.Dispose(); | ||
count++; | ||
} | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using YDotNet.Document; | ||
using YDotNet.Document.Cells; | ||
using YDotNet.Tests.Driver.Abstractions; | ||
|
||
namespace YDotNet.Tests.Driver.Tasks.Arrays; | ||
|
||
public class Get : 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), | ||
Input.Boolean(value: false) | ||
}); | ||
array.Get(transaction, index: 1); | ||
transaction.Commit(); | ||
|
||
doc.Dispose(); | ||
count++; | ||
} | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using YDotNet.Document; | ||
using YDotNet.Document.Cells; | ||
using YDotNet.Tests.Driver.Abstractions; | ||
|
||
namespace YDotNet.Tests.Driver.Tasks.Arrays; | ||
|
||
public class InsertRange : 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) }); | ||
transaction.Commit(); | ||
|
||
doc.Dispose(); | ||
count++; | ||
} | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using YDotNet.Document; | ||
using YDotNet.Document.Cells; | ||
using YDotNet.Tests.Driver.Abstractions; | ||
|
||
namespace YDotNet.Tests.Driver.Tasks.Arrays; | ||
|
||
public class Iterate : 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), | ||
Input.Boolean(value: false), | ||
Input.Undefined() | ||
}); | ||
array.Iterate(transaction).ToArray(); | ||
transaction.Commit(); | ||
|
||
doc.Dispose(); | ||
count++; | ||
} | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
} |
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
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; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using YDotNet.Document; | ||
using YDotNet.Document.Cells; | ||
using YDotNet.Tests.Driver.Abstractions; | ||
|
||
namespace YDotNet.Tests.Driver.Tasks.Arrays; | ||
|
||
public class Move : 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), | ||
Input.Boolean(value: false), | ||
Input.Undefined() | ||
}); | ||
array.Move(transaction, sourceIndex: 0, targetIndex: 2); | ||
transaction.Commit(); | ||
|
||
doc.Dispose(); | ||
count++; | ||
} | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using YDotNet.Document; | ||
using YDotNet.Document.Cells; | ||
using YDotNet.Tests.Driver.Abstractions; | ||
|
||
namespace YDotNet.Tests.Driver.Tasks.Arrays; | ||
|
||
public class Observe : 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 subscription = array.Observe(_ => { }); | ||
|
||
var transaction = doc.WriteTransaction(); | ||
array.InsertRange(transaction, index: 0, new[] { Input.Long(value: 2469L) }); | ||
transaction.Commit(); | ||
|
||
array.Unobserve(subscription); | ||
doc.Dispose(); | ||
count++; | ||
} | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
} |
Oops, something went wrong.