Repository navigation
Expand file tree
/
Copy pathBenchmark.java
More file actions
47 lines (39 loc) · 1.49 KB
/
Copy pathBenchmark.java
File metadata and controls
47 lines (39 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package fastcontentchunk.benchmark;
import fastcontentchunk.FastContentChunk;
import fastcontentchunk.FastContentChunkNative;
import fastcontentchunk.ChunkConfig;
import fastcontentchunk.ChunkMode;
import org.openjdk.jmh.annotations.*;
import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
@Warmup(iterations = 1, time = 1)
@Measurement(iterations = 2, time = 1)
@Fork(1)
public class Benchmark {
private FastContentChunk chunker;
private ChunkConfig recursiveConfig;
private String documentText;
@Setup
public void setup() {
chunker = new FastContentChunk();
recursiveConfig = new ChunkConfig(128, 16, ChunkMode.RECURSIVE);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 20; i++) {
sb.append("Section ").append(i).append("\n");
sb.append("This is paragraph ").append(i).append(" with SIMD accelerated token boundaries. ");
sb.append("Dr. med. Schmidt reported a 99.8% precision rate in automated RAG document chunking. ");
sb.append("The quick brown fox jumps over the lazy dog.\n\n");
}
documentText = sb.toString();
}
@Benchmark
public Object benchmarkNativeAVX2Offsets() {
return FastContentChunkNative.chunkToOffsets(documentText, 128, 16);
}
@Benchmark
public Object benchmarkRecursiveChunking() {
return chunker.chunk(documentText, recursiveConfig);
}
}