+ Added benchmark find command and internal structure
This commit is contained in:
@@ -2,6 +2,7 @@ package commands;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import core.benchmark.BenchmarkFramework;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
@@ -12,7 +13,15 @@ import dataStructures.UserInput;
|
||||
|
||||
public class CommandBenchmark extends Command
|
||||
{
|
||||
public CommandBenchmark(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
// Variables
|
||||
private BenchmarkFramework framework;
|
||||
|
||||
// Constructor
|
||||
public CommandBenchmark(KittyRole level, KittyRating rating)
|
||||
{
|
||||
super(level, rating);
|
||||
framework = new BenchmarkFramework();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String HelpText() { return LocStrings.Stub("BenchmarkInfo"); }
|
||||
@@ -20,24 +29,25 @@ public class CommandBenchmark extends Command
|
||||
@Override
|
||||
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
String [] info = input.args.split(" ");
|
||||
|
||||
switch(info[1].toLowerCase())
|
||||
if(input.args == null || input.args.length() == 0)
|
||||
{
|
||||
case "cpu":
|
||||
break;
|
||||
|
||||
case "gpu":
|
||||
break;
|
||||
|
||||
case "ram":
|
||||
break;
|
||||
|
||||
case "USB":
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
String output = HelpText();
|
||||
res.Call(output);
|
||||
return;
|
||||
}
|
||||
|
||||
String result = null;
|
||||
synchronized(framework)
|
||||
{
|
||||
result = framework.Run(input.args.trim());
|
||||
}
|
||||
|
||||
if(result == null)
|
||||
{
|
||||
res.Call(LocStrings.Stub("BenchmarkInvalid"));
|
||||
return;
|
||||
}
|
||||
|
||||
res.Call(result);
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ public class CommandRPG extends Command
|
||||
if(input.args == null || input.args.length() == 0)
|
||||
{
|
||||
String output = HelpText();
|
||||
System.out.println("Out: |" + output + "|");
|
||||
res.Call(output);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import core.rpg.RPGState;
|
||||
|
||||
public class RPGCommandBattleFight extends RPGCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public String OnRun(RPGState state, RPGInput input)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user