All Projects → tuxalin → Thst

tuxalin / Thst

Licence: mit
Templated hierarchical spatial trees designed for high-peformance.

Programming Languages

cpp
1120 projects

Projects that are alternatives of or similar to Thst

Http Benchmark Tornado
基于Python Tornado的高性能http性能测试工具。Java Netty版: https://github.com/junneyang/http-benchmark-netty 。
Stars: ✭ 67 (-20.24%)
Mutual labels:  benchmark
Asr benchmark
Program to benchmark various speech recognition APIs
Stars: ✭ 71 (-15.48%)
Mutual labels:  benchmark
Labench
Latency Benchmarking tool
Stars: ✭ 75 (-10.71%)
Mutual labels:  benchmark
The Cpp Abstraction Penalty
Modern C++ benchmarking
Stars: ✭ 69 (-17.86%)
Mutual labels:  benchmark
Appdocs
Application Performance Optimization Summary
Stars: ✭ 1,169 (+1291.67%)
Mutual labels:  benchmark
Ben
Your benchmark assistant, written in Go.
Stars: ✭ 72 (-14.29%)
Mutual labels:  benchmark
Evalne
Source code for EvalNE, a Python library for evaluating Network Embedding methods.
Stars: ✭ 67 (-20.24%)
Mutual labels:  benchmark
Fashion Mnist
A MNIST-like fashion product database. Benchmark 👇
Stars: ✭ 9,675 (+11417.86%)
Mutual labels:  benchmark
Ossf Cve Benchmark
The OpenSSF CVE Benchmark consists of code and metadata for over 200 real life CVEs, as well as tooling to analyze the vulnerable codebases using a variety of static analysis security testing (SAST) tools and generate reports to evaluate those tools.
Stars: ✭ 71 (-15.48%)
Mutual labels:  benchmark
1m Go Tcp Server
benchmarks for implementation of servers which support 1 million connections
Stars: ✭ 1,193 (+1320.24%)
Mutual labels:  benchmark
Quantum Benchmarks
benchmarking quantum circuit emulators for your daily research usage
Stars: ✭ 70 (-16.67%)
Mutual labels:  benchmark
Attabench
Microbenchmarking app for Swift with nice log-log plots
Stars: ✭ 1,167 (+1289.29%)
Mutual labels:  benchmark
Jsperf.com
jsperf.com v2. https://github.com/h5bp/lazyweb-requests/issues/174
Stars: ✭ 1,178 (+1302.38%)
Mutual labels:  benchmark
Web Components Benchmark
Web Components benchmark for a various Web Components technologies
Stars: ✭ 69 (-17.86%)
Mutual labels:  benchmark
Xrautomatedtests
XRAutomatedTests is where you can find functional, graphics, performance, and other types of automated tests for your XR Unity development.
Stars: ✭ 77 (-8.33%)
Mutual labels:  benchmark
Crypto Bench
Benchmarks for crypto libraries (in Rust, or with Rust bindings)
Stars: ✭ 67 (-20.24%)
Mutual labels:  benchmark
Service Mesh Benchmark
Stars: ✭ 72 (-14.29%)
Mutual labels:  benchmark
Php Arrays In Memory Comparison
How to store 11kk items in memory? Comparison of methods: array vs object vs SplFixedArray vs pack vs swoole_table vs swoole_pack vs redis vs memsql vs node.js arrays in php7
Stars: ✭ 83 (-1.19%)
Mutual labels:  benchmark
Vkmark
Vulkan benchmark
Stars: ✭ 80 (-4.76%)
Mutual labels:  benchmark
Unsafe
Assorted java classes that make use of sun.misc.Unsafe
Stars: ✭ 74 (-11.9%)
Mutual labels:  benchmark

Hierarchical spatial trees

Build Status Language License

Templated hierarchical spatial trees designed for high-performance and hierarchical spatial partitioning use cases.

Features

There are two tree implementations, a multi-dimensional RTree and a two-dimensional QuadTree.

Some of the currently implemented features are:

  • hierarchical, you can add values to the internal branch nodes or traverse them
  • leaf and depth-first tree traversals for spatial partitioning, via custom iterators
  • custom indexable getter similar to boost's
  • hierarchical query
  • nearest neighbour search
  • conditional insert with custom predicates
  • support for custom allocators for internal nodes
  • estimation for node count given a number of items
  • tagging of internal nodes
  • the spatial trees have almost identical interfaces
  • lightweight, resulting in faster compile times compared to boost(eg. benchmark compilation: 35,3 sec vs 1,4 sec)
  • C++03 support

Installation

The implementation is header only, it's only requirement is at least (C++03) support.

Usage

How to create and insert items to the trees:

  	spatial::QuadTree<int, Box2<int>, 2> qtree(bbox.min, bbox.max);
  	spatial::RTree<int, Box2<int>, 2> rtree;

	const Box2<int> kBoxes[] = {...};
  	qtree.insert(kBoxes, kBoxes + sizeof(kBoxes) / sizeof(kBoxes[0]));
  	rtree.insert(kBoxes, kBoxes + sizeof(kBoxes) / sizeof(kBoxes[0]));
    
  	Box2<int> box = {{7, 3}, {14, 6}};
  	qtree.insert(box);
  	rtree.insert(box);

Conditional insert:

    const decltype(rtree)::bbox_type boxToAdd = {{7, 4}, {14, 6}};
    bool wasAdded =
        rtree.insert(boxToAdd, [&boxToAdd](const decltype(rtree)::bbox_type &bbox) {
          return !bbox.overlaps(boxToAdd);
        });

How to use the indexable getter:

 	struct Object {
  		spatial::BoundingBox<int, 2> bbox;
  		std::string name;
  	};

  	// helps to get the bounding of the items inserted
  	struct Indexable {
    	const int *min(const Object &value) const { return value.bbox.min; }
    	const int *max(const Object &value) const { return value.bbox.max; }
  	};

  	spatial::QuadTree<int, Object, 2, Indexable> qtree(bbox.min, bbox.max);
  	qtree.insert(objects.begin(), objects.end());

  	spatial::RTree<int, Object, 2, 4, 2, Indexable> rtree;
  	rtree.insert(objects.begin(), objects.end());

Leaf and depth traversal:

    spatial::RTree<int, Object, 2, 4, 2, Indexable> rtree;

    // gives the spatial partioning order within the tree
    for (auto it = rtree.lbegin(); it.valid(); it.next()) {
      std::cout << (*it).name << "\n";
    }

    assert(rtree.levels() > 0);
    for (auto it = rtree.dbegin(); it.valid(); it.next()) {

      // traverse current children of the parent node(i.e. upper level)
      for (auto nodeIt = it.child(); nodeIt.valid(); nodeIt.next()) {
        std::cout << "level: " << nodeIt.level() << " " << (*nodeIt).name
                  << "\n";
      }
      // level of the current internal/hierachical node
      std::cout << "level: " << it.level() << "\n";
    }

How to use the search algorithms:

    Box2<int> searchBox = {{0, 0}, {8, 31}};

    std::vector<Box2<int>> results;
    rtree.query(spatial::intersects<2>(searchBox.min, searchBox.max), std::back_inserter(results));
    rtree.query(spatial::contains<2>(searchBox.min, searchBox.max), std::back_inserter(results));

    // to be used only if inserted points into the tree
    rtree.query(spatial::within<2>(searchBox.min, searchBox.max), std::back_inserter(results));

    // hierachical query that will break the search if a node is fully contained
    rtree.hierachical_query(spatial::intersects<2>(searchBox.min, searchBox.max), std::back_inserter(results));

    // neatest neighbor search
    rtree.nearest(point, radius, std::back_inserter(results));

Be sure to check the test and examples folders for more detailed info.

Benchmarks

Benchmark setup is based on spatial_index_benchmark by Mateusz Loskot and Adam Wulkiewicz.

Complete set of result logs in results directory.

Results

HW: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz, 16 GB RAM; OS: macOS Sierra 10.12.16

  • Loading times for each of the R-tree construction methods

load thst_vs_bgi

load boost::geometry

load thst

  • Query times for each of the R-tree construction methods

query thst_vs_bgi

query boost::geometry

query thst

query thst

  • Dynamic use case, average time for each of the R-tree construction methods

dynamic thst_vs_bgi

For more detailed benchmark results check the benchmark directory.

Legend


  • bgi - boost::geometry::index, compile time
  • thst - thst
  • ct - compile-time specification of rtree parameters
  • rt (or non suffix) - Boost.Geometry-only, run-time specification of rtree parameters
  • L - linear
  • Q - quadratic
  • QT - quadtree
  • R - rstar
  • itr (or no suffix) - iterative insertion method of building rtree
  • blk - bulk loading method of building R-tree (custom algorithm for bgi)
  • custom - custom allocator variant for thst(cache friendly, linear memory)
  • sphere - sphere volume for computing the boxes's volume, better splitting but costlier
  • insert 1000000 - number of objects small random boxes
  • query 100000 - number of instersection-based queries with random boxes 10x larger than those inserted
  • dynamic 200 - number of runs composed of clear, instersection-based queries and insert with small random boxes

Future improvements

Possible improvements are:

  • RTree bulk loading
  • OCtree implementation
  • reduced memory footprint for 1D and leaves
  • support for multiple splitting heuristics
  • SSE optimizations

Contributing

Based on:

Bug reports and pull requests are welcome on GitHub at https://github.com/tuxalin/thst.

License

The code is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].