davidmoten / davidmoten/rtree

[Question] A R-Tree search performance question

Open
#96 7 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Java
Stars
1.1k
Forks
218
Avg merge
2m
Merged PRs (30d)
1

Description

Hi Dave,

I have a performance related question.

I created a R-Tree and added 3000 Line objects to it . Then I create a new Line object and call the R-Tree's search() funciton to search all the lines that intersect with the input line.

My question is **the first search() call cost about 50ms. After the search() is called multiple times. I call the search() again , it only cost 1~5ms.** I want to know why?

Does R-Tree need some warm up process? Or maybe the JIT matters?

I am looking forward for your reply.

Thanks,
Jerry Shi

-----------------------------------------------------------------
The following is my pseudo code:

RTree tree = RTree.maxChildren(5).create();
for (int i = 0; i<1000; ++i){
tree = tree.add(i+"", createRandomLine(100,500));
}

Line line = Geometries.line(10.5, 10.5, 100, 200);

**//the first call cost about 50ms;**
tree.search(line).subscribe((t)-> {});

for (int i = 0; i<10000; ++i){
Line line = Geometries.line(1.0,1.0,i,i);
tree.search(line).subscribe((t)-> {});
}

**//the same call cost about 1~5ms;**
tree.search(line).subscribe((t)-> {});

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.