+ Added benchmark find command and internal structure

This commit is contained in:
Matthew Cech
2019-05-05 15:56:55 -07:00
parent 645e632dcb
commit 40d4812e2a
13 changed files with 185 additions and 39 deletions
@@ -0,0 +1,47 @@
package commands.benchmark;
import java.util.List;
import core.benchmark.*;
public class BenchmarkCommandFind extends BenchmarkCommand
{
final char lineDelimiter = '\n';
public String OnRun(BenchmarkManager manager, BenchmarkInput input)
{
String output = "";
String searchString = input.value.trim();
List<BenchmarkEntry> entries = manager.FindModel(searchString);
if(entries.size() > 0)
{
output += "```" + lineDelimiter;
int max = entries.size();
final int listMax = 30;
boolean fencepost = true;
for(int i = 0; i < entries.size() && i < listMax; ++i)
{
BenchmarkEntry entry = entries.get(i);
if(!fencepost)
output += lineDelimiter;
fencepost = false;
output += entry.type + ": "+ entry.model;
}
if(max > listMax)
output += "\n\nPlus " + (max - listMax) + " more items...";
output += "```";
}
else
{
output = "Couldn't find any models matching the search `" + searchString + "`!";
}
return output;
}
}