added testing + some performance improvements
This commit is contained in:
parent
bd07c4b151
commit
73ba086c54
5 changed files with 162 additions and 2 deletions
|
@ -2,5 +2,4 @@ FileVersion = 1
|
||||||
|
|
||||||
[Project]
|
[Project]
|
||||||
Name = "Bofa"
|
Name = "Bofa"
|
||||||
TargetType = "BeefLib"
|
|
||||||
StartupObject = "Bofa.Program"
|
StartupObject = "Bofa.Program"
|
||||||
|
|
|
@ -6,3 +6,7 @@ StartupProject = "Bofa"
|
||||||
|
|
||||||
[Configs.Test.Win64]
|
[Configs.Test.Win64]
|
||||||
LargeStrings = true
|
LargeStrings = true
|
||||||
|
|
||||||
|
[Configs.Debug.Win64]
|
||||||
|
LargeStrings = true
|
||||||
|
LargeCollections = true
|
||||||
|
|
|
@ -2,6 +2,7 @@ namespace Bofa;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Security.Cryptography;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
using Bofa.Parser;
|
using Bofa.Parser;
|
||||||
|
@ -17,6 +18,10 @@ class BofaParser
|
||||||
|
|
||||||
public static void Parse(Stream pToParse, List<Bofa> pResult, List<int64> pErrors)
|
public static void Parse(Stream pToParse, List<Bofa> pResult, List<int64> pErrors)
|
||||||
{
|
{
|
||||||
|
HashSet<SHA256Hash> lowLevelObjects = new .(100);
|
||||||
|
defer delete lowLevelObjects;
|
||||||
|
|
||||||
|
|
||||||
if (pToParse == null || pResult == null)
|
if (pToParse == null || pResult == null)
|
||||||
{ //Cannot parse what doesnt exist
|
{ //Cannot parse what doesnt exist
|
||||||
pErrors.Add(-1);
|
pErrors.Add(-1);
|
||||||
|
@ -52,8 +57,10 @@ class BofaParser
|
||||||
//If we are on the lowest level we can just add them here
|
//If we are on the lowest level we can just add them here
|
||||||
if(entry.Depth == 0 && entry.Type ==.Bofa)
|
if(entry.Depth == 0 && entry.Type ==.Bofa)
|
||||||
{
|
{
|
||||||
if(pResult.FindIndex(scope (x) => { return x.Name == entry.Data.Bofa.Name;}) < 0)
|
if(lowLevelObjects.Add(SHA256.Hash(cast!<Span<uint8>>(entry.Data.Bofa.Name))))
|
||||||
|
{
|
||||||
pResult.Add(entry.Data.Bofa);
|
pResult.Add(entry.Data.Bofa);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pErrors.Add(entry.Line); //Dublicate name error
|
pErrors.Add(entry.Line); //Dublicate name error
|
||||||
|
@ -305,4 +312,5 @@ class BofaParser
|
||||||
}
|
}
|
||||||
return (.(pLine, 0, (i < pLine.Length) ? i - 1 : i), .(pLine, i));
|
return (.(pLine, 0, (i < pLine.Length) ? i - 1 : i), .(pLine, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
39
src/Program.bf
Normal file
39
src/Program.bf
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Bofa
|
||||||
|
{
|
||||||
|
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
public static void Main()
|
||||||
|
{
|
||||||
|
Bofa.Testing.Profiling.Profiling_Normal_Large();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace System.Security.Cryptography
|
||||||
|
{
|
||||||
|
extension SHA256Hash : IHashable
|
||||||
|
{
|
||||||
|
public int GetHashCode()
|
||||||
|
{
|
||||||
|
return this.mHash[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace System
|
||||||
|
{
|
||||||
|
static
|
||||||
|
{
|
||||||
|
public static mixin cast<T>(var v)
|
||||||
|
{
|
||||||
|
*(T*)(void*)&v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,115 @@
|
||||||
namespace Bofa.Testing;
|
namespace Bofa.Testing;
|
||||||
|
|
||||||
|
using Bofa;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
class Profiling
|
class Profiling
|
||||||
{
|
{
|
||||||
|
[Test(Name = "Profiling: normal 1000 * 15")]
|
||||||
|
public static void Profiling_Normal()
|
||||||
|
{
|
||||||
|
for (int i < 1000)
|
||||||
|
{
|
||||||
|
String content = """
|
||||||
|
l one line of text
|
||||||
|
b bool true
|
||||||
|
# saoidsaodsad
|
||||||
|
t text goes here
|
||||||
|
- Text addendum
|
||||||
|
n tone 12.5
|
||||||
|
#husdhfiudshfds
|
||||||
|
bn biggie 65645645645.6
|
||||||
|
i int 234345
|
||||||
|
|
||||||
|
|
||||||
|
bi bint 38432847329847329
|
||||||
|
o object
|
||||||
|
b content true
|
||||||
|
a array
|
||||||
|
b content true
|
||||||
|
b content true
|
||||||
|
""";
|
||||||
|
List<Bofa> output = new .();
|
||||||
|
List<int64> errors = new .();
|
||||||
|
BofaParser.Parse(content, output, errors);
|
||||||
|
DeleteContainerAndItems!(output);
|
||||||
|
delete errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test(Name = "Profiling: normal 10 * 1500")]
|
||||||
|
public static void Profiling_Normal_Medium()
|
||||||
|
{
|
||||||
|
for (int i < 10)
|
||||||
|
{
|
||||||
|
String toParse = new .(10 * 1500);
|
||||||
|
for (int ii < 100)
|
||||||
|
{
|
||||||
|
toParse.Append(scope $"""
|
||||||
|
l one{ii} line of text
|
||||||
|
b bool{ii} true
|
||||||
|
# saoidsaodsad
|
||||||
|
t text{ii} goes here
|
||||||
|
- Text addendum
|
||||||
|
n tone{ii} 12.5
|
||||||
|
#husdhfiudshfds
|
||||||
|
bn biggie{ii} 65645645645.6
|
||||||
|
i int{ii} 234345
|
||||||
|
|
||||||
|
|
||||||
|
bi bint{ii} 38432847329847329
|
||||||
|
o object{ii}
|
||||||
|
b content true
|
||||||
|
a array{ii}
|
||||||
|
b content true
|
||||||
|
b content true
|
||||||
|
""");
|
||||||
|
}
|
||||||
|
List<Bofa> output = new .();
|
||||||
|
List<int64> errors = new .();
|
||||||
|
BofaParser.Parse(toParse, output, errors);
|
||||||
|
DeleteContainerAndItems!(output);
|
||||||
|
delete errors;
|
||||||
|
delete toParse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Test(Name = "Profiling: normal 1 * 150000")]
|
||||||
|
public static void Profiling_Normal_Large()
|
||||||
|
{
|
||||||
|
String toParse = new .(10 * 150000);
|
||||||
|
for (int ii < 10000)
|
||||||
|
{
|
||||||
|
toParse.Append(scope $"""
|
||||||
|
l one{ii} line of text
|
||||||
|
b bool{ii} true
|
||||||
|
# saoidsaodsad
|
||||||
|
t text{ii} goes here
|
||||||
|
- Text addendum
|
||||||
|
n tone{ii} 12.5
|
||||||
|
#husdhfiudshfds
|
||||||
|
bn biggie{ii} 65645645645.6
|
||||||
|
i int{ii} 234345
|
||||||
|
|
||||||
|
|
||||||
|
bi bint{ii} 38432847329847329
|
||||||
|
o object{ii}
|
||||||
|
b content true
|
||||||
|
a array{ii}
|
||||||
|
b content true
|
||||||
|
b content true
|
||||||
|
|
||||||
|
""");
|
||||||
|
}
|
||||||
|
List<Bofa> output = new .();
|
||||||
|
List<int64> errors = new .();
|
||||||
|
BofaParser.Parse(toParse, output, errors);
|
||||||
|
DeleteContainerAndItems!(output);
|
||||||
|
delete errors;
|
||||||
|
delete toParse;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue