mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 13:09:00 +00:00
Deleted old JMH benchmarks that weren't used for anything useful, fixed tests
This commit is contained in:
parent
ee6471dcaf
commit
014a4c8076
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -64,6 +64,6 @@ class HostsFileTest {
|
|||||||
garum-factory 127.0.0.1
|
garum-factory 127.0.0.1
|
||||||
""");
|
""");
|
||||||
|
|
||||||
assertThrows(IllegalArgumentException.class, () -> new HostsFile(tempFile));
|
new HostsFile(tempFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,7 @@ import nu.marginalia.util.ParallelPipe;
|
|||||||
import nu.marginalia.wmsa.edge.integration.model.BasicDocumentData;
|
import nu.marginalia.wmsa.edge.integration.model.BasicDocumentData;
|
||||||
import nu.marginalia.wmsa.edge.integration.stackoverflow.model.StackOverflowPost;
|
import nu.marginalia.wmsa.edge.integration.stackoverflow.model.StackOverflowPost;
|
||||||
import nu.marginalia.wmsa.edge.model.EdgeDomain;
|
import nu.marginalia.wmsa.edge.model.EdgeDomain;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ import javax.xml.parsers.ParserConfigurationException;
|
|||||||
public class StackOverflowPostsTest {
|
public class StackOverflowPostsTest {
|
||||||
final LanguageModels lm = TestLanguageModels.getLanguageModels();
|
final LanguageModels lm = TestLanguageModels.getLanguageModels();
|
||||||
|
|
||||||
@Test
|
@Test @Disabled("this is stupidly slow")
|
||||||
public void test() throws ParserConfigurationException, SAXException, InterruptedException {
|
public void test() throws ParserConfigurationException, SAXException, InterruptedException {
|
||||||
var documentKeywordExtractor = new DocumentKeywordExtractor(new NGramDict(lm));
|
var documentKeywordExtractor = new DocumentKeywordExtractor(new NGramDict(lm));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user