+ Added formattable benchmark for returns and adjusted to vaguely fuzzy-search

This commit is contained in:
Matthew Cech
2019-05-05 18:55:05 -07:00
parent 3a8306f1e6
commit 99667330df
10 changed files with 248 additions and 30 deletions
@@ -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);
}
}