Deleted old JMH benchmarks that weren't used for anything useful, fixed tests

This commit is contained in:
vlofgren 2022-05-25 20:43:30 +02:00
parent ee6471dcaf
commit 014a4c8076
4 changed files with 3 additions and 107 deletions

View file

@ -1,37 +0,0 @@
package bs_vs_ls;
import org.openjdk.jmh.annotations.*;
import java.util.Arrays;
import java.util.stream.LongStream;
public class BinSearchVsLinSearch {
static final long[] data = LongStream.generate(() -> (long) (Long.MAX_VALUE * Math.random())).limit(512).sorted().toArray();
@State(Scope.Thread)
public static class Target {
long targetValue = 0;
@Setup(Level.Invocation)
public void setUp() {
targetValue = data[(int)(data.length * Math.random())];
}
}
// @Benchmark
public long testBs(Target t) {
return Arrays.binarySearch(data, t.targetValue);
}
// @Benchmark
public long testLs(Target t) {
for (int i = 0; i < 512; i++) {
if (data[i] > t.targetValue)
break;
else if (data[i] == t.targetValue)
return i;
}
return -1;
}
}

View file

@ -1,68 +0,0 @@
package bs_vs_ls;
import nu.marginalia.util.multimap.MultimapFileLong;
import nu.marginalia.util.multimap.MultimapSearcher;
import org.openjdk.jmh.annotations.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.LongStream;
public class BinSearchVsLinSearch2 {
static long[] data = LongStream.generate(() -> (long) (Long.MAX_VALUE * Math.random())).limit(512).sorted().toArray();
@State(Scope.Benchmark)
public static class Target {
Path tf;
MultimapFileLong file;
MultimapSearcher searcher;
final long[] data = new long[512];
{
try {
tf = Files.createTempFile("tmpFileIOTest", "dat");
file = MultimapFileLong.forOutput(tf, 1024);
searcher = file.createSearcher();
for (int i = 0; i < 65535; i++) {
file.put(i, i);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Measurement(iterations = 1)
@Warmup(iterations = 1)
@Benchmark
public long testLs(Target t) {
int target = (int)(4096 + 512 * Math.random());
for (int i = 4096; i < (4096+512); i++) {
long val = t.file.get(i);
if (val > target)
break;
if (val == target)
return val;
}
return -1;
}
@Measurement(iterations = 1)
@Warmup(iterations = 1)
@Benchmark
public long testLs2(Target t) {
int target = (int)(4096 + 512 * Math.random());
t.file.read(t.data, 4096);
for (int i = 0; i < (512); i++) {
long val = t.file.get(i);
if (val > target)
break;
if (val == target)
return val;
}
return -1;
}
}

View file

@ -64,6 +64,6 @@ class HostsFileTest {
garum-factory 127.0.0.1
""");
assertThrows(IllegalArgumentException.class, () -> new HostsFile(tempFile));
new HostsFile(tempFile);
}
}

View file

@ -9,6 +9,7 @@ import nu.marginalia.util.ParallelPipe;
import nu.marginalia.wmsa.edge.integration.model.BasicDocumentData;
import nu.marginalia.wmsa.edge.integration.stackoverflow.model.StackOverflowPost;
import nu.marginalia.wmsa.edge.model.EdgeDomain;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.xml.sax.SAXException;
@ -17,7 +18,7 @@ import javax.xml.parsers.ParserConfigurationException;
public class StackOverflowPostsTest {
final LanguageModels lm = TestLanguageModels.getLanguageModels();
@Test
@Test @Disabled("this is stupidly slow")
public void test() throws ParserConfigurationException, SAXException, InterruptedException {
var documentKeywordExtractor = new DocumentKeywordExtractor(new NGramDict(lm));