+ Added formattable benchmark for returns and adjusted to vaguely fuzzy-search
This commit is contained in:
@@ -2,6 +2,7 @@ package commands;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import core.benchmark.BenchmarkFormattable;
|
||||
import core.benchmark.BenchmarkFramework;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
@@ -36,18 +37,18 @@ public class CommandBenchmark extends Command
|
||||
return;
|
||||
}
|
||||
|
||||
String result = null;
|
||||
BenchmarkFormattable commandOutput = null;
|
||||
synchronized(framework)
|
||||
{
|
||||
result = framework.Run(input.args.trim());
|
||||
commandOutput = framework.Run(input.args.trim());
|
||||
}
|
||||
|
||||
if(result == null)
|
||||
if(commandOutput == null)
|
||||
{
|
||||
res.Call(LocStrings.Stub("BenchmarkInvalid"));
|
||||
return;
|
||||
}
|
||||
|
||||
res.Call(result);
|
||||
commandOutput.Call(res);
|
||||
}
|
||||
}
|
||||
@@ -4,19 +4,20 @@ import java.util.List;
|
||||
|
||||
import core.benchmark.BenchmarkCommand;
|
||||
import core.benchmark.BenchmarkEntry;
|
||||
import core.benchmark.BenchmarkFormattable;
|
||||
import core.benchmark.BenchmarkInput;
|
||||
import core.benchmark.BenchmarkManager;
|
||||
|
||||
public class BenchmarkCommandCompare extends BenchmarkCommand
|
||||
{
|
||||
public String OnRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
public BenchmarkFormattable OnRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
{
|
||||
final String lineDelimiter = "\n";
|
||||
String output = "";
|
||||
String[] inputSplit = input.value.trim().split("\\s+");
|
||||
|
||||
if(inputSplit.length < 2)
|
||||
return "You must to specify 2 models to compare!";
|
||||
return new BenchmarkFormattable("You must to specify 2 models to compare!");
|
||||
|
||||
for(int i = 0; i < inputSplit.length; ++i)
|
||||
{
|
||||
@@ -38,6 +39,6 @@ public class BenchmarkCommandCompare extends BenchmarkCommand
|
||||
output += "----------";
|
||||
}
|
||||
|
||||
return output;
|
||||
return new BenchmarkFormattable(output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ import core.benchmark.*;
|
||||
|
||||
public class BenchmarkCommandFind extends BenchmarkCommand
|
||||
{
|
||||
private final char lineDelimiter = '\n';
|
||||
private final String lineDelimiter = "\n";
|
||||
private final int listMax = 30;
|
||||
|
||||
public String OnRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
public BenchmarkFormattable OnRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
{
|
||||
String output = "";
|
||||
String searchString = input.value.trim();
|
||||
@@ -42,6 +42,6 @@ public class BenchmarkCommandFind extends BenchmarkCommand
|
||||
output = "Couldn't find any models matching the search `" + searchString + "`!";
|
||||
}
|
||||
|
||||
return output;
|
||||
return new BenchmarkFormattable(output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,11 @@ import java.util.List;
|
||||
|
||||
import core.benchmark.BenchmarkCommand;
|
||||
import core.benchmark.BenchmarkEntry;
|
||||
import core.benchmark.BenchmarkFormattable;
|
||||
import core.benchmark.BenchmarkInput;
|
||||
import core.benchmark.BenchmarkManager;
|
||||
import dataStructures.KittyEmbed;
|
||||
import java.awt.Color;
|
||||
|
||||
public class BenchmarkCommandInfo extends BenchmarkCommand
|
||||
{
|
||||
@@ -20,27 +23,76 @@ public class BenchmarkCommandInfo extends BenchmarkCommand
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public static KittyEmbed FormatInfoEmbed(BenchmarkEntry entry)
|
||||
{
|
||||
// Populate general embed info
|
||||
KittyEmbed embed = new KittyEmbed();
|
||||
|
||||
embed.title = "" + entry.brand + " " + entry.model + "" + lineDelimiter;
|
||||
embed.authorLink = entry.url;
|
||||
embed.authorImage = "https://kittybot.net/assets/generic/baseline_assessment_black_48dp.png";
|
||||
embed.authorText = "[view online]";
|
||||
embed.color = Color.LIGHT_GRAY;
|
||||
embed.descriptionText = "Average Bench: " + entry.benchmark + "%";
|
||||
|
||||
// Brand coloring
|
||||
String brandClean = entry.brand.toLowerCase().trim();
|
||||
|
||||
if(brandClean.contains("intel"))
|
||||
embed.color = Color.getHSBColor((float) (205.0/360), 1.00f, 0.75f);
|
||||
else if(brandClean.contains("amd"))
|
||||
embed.color = Color.getHSBColor((float) (357.0/360), 0.88f, 0.92f);
|
||||
else if (brandClean.contains("nvidia"))
|
||||
embed.color = Color.getHSBColor((float) (081.0/360), 1.00f, 0.72f);
|
||||
|
||||
// Add relative performance numbers
|
||||
switch(entry.type)
|
||||
{
|
||||
case CPU:
|
||||
embed.footerText = "(100% ~ Intel i7-7700k)";
|
||||
break;
|
||||
case GPU:
|
||||
embed.footerText = "(100% ~ Nvidia GTX 1070)";
|
||||
break;
|
||||
case SSD:
|
||||
embed.footerText = "(100% ~ Samsung 850 Pro)";
|
||||
break;
|
||||
case HDD:
|
||||
embed.footerText = "(100% ~ Seagate Baracuda 3TB (2016))";
|
||||
break;
|
||||
case RAM:
|
||||
embed.footerText = "(100% ~ Corsair Vengence LPX 2666 C15 4x8GB w/ Intel Skylake)";
|
||||
break;
|
||||
case USB:
|
||||
embed.footerText = "(100% ~ Sandisk Extreme 64GB)";
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
return embed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String OnRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
public BenchmarkFormattable OnRun(BenchmarkManager manager, BenchmarkInput input)
|
||||
{
|
||||
String searchString = input.value.trim();
|
||||
|
||||
String output = "";
|
||||
output += lineDelimiter;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
List<BenchmarkEntry> entries = manager.FindModel(searchString);
|
||||
|
||||
if(entries.size() < 1)
|
||||
output += "Couldn't find any models containing `" + searchString + "`!";
|
||||
return new BenchmarkFormattable("Couldn't find any models containing `" + searchString + "`!");
|
||||
|
||||
output += FormatInfo(entries.get(0));
|
||||
output += lineDelimiter;
|
||||
List<BenchmarkEntry> sortedEntries = manager.EvaluateLevenshteinDistance(entries, searchString);
|
||||
BenchmarkEntry entry = sortedEntries.get(0);
|
||||
KittyEmbed embed = FormatInfoEmbed(entry);
|
||||
|
||||
if(entries.size() > 1)
|
||||
output += "_chose " + entries.get(0).model + " from " + entries.size() + " potential components. To see others, try the command `benchmark find " + searchString +"`_)";
|
||||
embed.footerText += " (Chose the " + entry.model + " from " + entries.size() + " potential components. To see others, try the command 'benchmark find " + searchString +"')";
|
||||
|
||||
return output;
|
||||
embed.footerText += " (took " + (System.currentTimeMillis() - start) + "ms)";
|
||||
|
||||
return new BenchmarkFormattable(embed);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user