Skip to content

Commit 3bc2eef

Browse files
trcrsiredombhntlar
andauthored
Add Docs PWA placeholder, so we can list it on cloudflare as a PWA (#1238)
* unfinshed overhual of c's fwrite/fread etc * done * self-reference for pyobject_file * No exemption of ANY devices for this library for anti-tivo It is scary to think self-driving cars could be planted with backdoors to kill anyone. That is INSANE * [Qt] qiodevice uses new mechanism * qiodevice * initial_attempt for strbset * initial attempt for str_btreeset.h * btree * btreeset * [btree_set] testing * [str_btree_set] move the example to test * set * [btree] root needs to change in the case when node->parent == nullptr * str * [btree] set nullptr for root? * str_btree_set * str_btree_set2.h * put debugging information in it first * [str_btree_set] implement more logic for btree * [btreeset] more logic for fix up * [BTree] Fix & missing in str_btree_set.h * btree * [str_btree_set] Fix str_btree_set.h * [str_btree_set] Some changes to fuzz the code * [btree] Fix btree * [btree] add fuzzing to debug the code * rd * fix bug in str_bree_set * fix branch in str_btree_set.h * fix str_btree_set * update test * clang-format for str_btree_set_reverse.cc * str_btree_set * add a test for str_btree_set_input * [btree] fix one more bug here * [str_btree_set] add fast_io_dsal/str_btree_set.h * [str_btree_set] fix str_btree_set.h * [str_btree_set] add a benchmark for str_btree_set * [str_btree_set] add contains * [str_btree_set] add ::std::unordered_set bench * [str_btree_set] fix up str btree set * [str_tree_set] btree should only allow even numbers of key * [str_btree_set] add some benchmarks * [str_btree_set] fix main.rs in rustbtree bench * [str_btree_set] fix main.rs * [str_btree_set] rust is a bs lang wtf design a random number generate without std + low...=high or low... high_exclusive * [str_btree_set] use two string types * disable benchmark for str_btree_set * [str_btree_set] Fix the test CI * [str_tree_set] add iterator implementation for str_btree_set * [str_btree_set] str_btree_set add leftmost and rightmost * [str_tree_set] implement str_btree iterator * [str_btree_set] add benchmarks for iteration * [str_btree_set] remove nullptr check for -- iterator * [str_btree_set] fix operator-- for iterator * [str_btree_set] add iteration bench for abseil * [btree] add the bench to rust code * [btree] add iteration bench for abseil_btree_set_fast_io * [str_btree_set] add find method * [str_btree_set] implement find() * [str_btree_set] put a placeholder for erase * [str_btree_set] fix around str_btree_set * [str_btree_set] merge code * Add sock_protocol QUIC * add some content to str_btree_set * btree * add a simple wifianalyzer * add scanning logic * add logic to print out even after scanning timeout * wifi quality * win32 * add covers * remove ln * pin12 * Fix warnings for char32_t casting * correctly ignore wifianalyzer example * remove unused variable * Use reverse_iterator instead of reverse_view since CI does not support it * Fix str_btree_set.cc * fix ifdef issue for printf * using a universal type convert for fixing the is_dos_file_invalid_character merging issue * Change the example's min len for password ans specialpassword to 12 to match the PWA GenPass version. * implement full str_btree_set's erase * add str_btree_erase fuzzer * add the erase that covers entire function * use chatgpt to rewrite the code * clang-format to str_btree_set.h * extract fix_child_links in str_btree_set * call function needs to use full name * Add docs --------- Co-authored-by: ombhntlar <tfnhtar@ombhntlars-Mac-mini.lan>
1 parent 3190223 commit 3bc2eef

File tree

42 files changed

+2427
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2427
-93
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
["str_btree_set"]
2+
ignore = true
3+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include <unordered_set>
2+
#include <string>
3+
#include <absl/container/btree_set.h>
4+
#include <fast_io.h>
5+
#include <fast_io_dsal/string.h>
6+
#include <fast_io_driver/timer.h>
7+
#include "gentest.h"
8+
9+
int main()
10+
{
11+
auto vec{::gentest<::std::string>()};
12+
::fast_io::timer t(u8"str_btree_set");
13+
::absl::btree_set<typename decltype(vec)::value_type> bset;
14+
{
15+
::fast_io::timer t(u8"insert");
16+
for (auto const &e : vec)
17+
{
18+
bset.insert(e);
19+
}
20+
}
21+
{
22+
::std::size_t count{};
23+
{
24+
::fast_io::timer t(u8"contains");
25+
for (auto const &e : vec)
26+
{
27+
count += static_cast<::std::size_t>(bset.contains(e));
28+
}
29+
}
30+
::fast_io::io::perrln("count=", count);
31+
}
32+
{
33+
::std::size_t total_size{};
34+
{
35+
::fast_io::timer t(u8"iteration");
36+
for (auto const &e : bset)
37+
{
38+
total_size += e.size();
39+
}
40+
}
41+
::fast_io::io::perrln("total_size=", total_size);
42+
}
43+
{
44+
::std::size_t total_size{};
45+
{
46+
::fast_io::timer t(u8"reverse iteration");
47+
for (auto const &e : ::std::ranges::reverse_view(bset))
48+
{
49+
total_size += e.size();
50+
}
51+
}
52+
::fast_io::io::perrln("total_size=", total_size);
53+
}
54+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include <unordered_set>
2+
#include <string>
3+
#include <absl/container/btree_set.h>
4+
#include <fast_io.h>
5+
#include <fast_io_dsal/string.h>
6+
#include <fast_io_driver/timer.h>
7+
#include "gentest.h"
8+
9+
int main()
10+
{
11+
auto vec{::gentest()};
12+
::fast_io::timer t(u8"str_btree_set");
13+
::absl::btree_set<::fast_io::string> bset;
14+
{
15+
::fast_io::timer t(u8"insert");
16+
for (auto const &e : vec)
17+
{
18+
bset.insert(e);
19+
}
20+
}
21+
{
22+
::std::size_t count{};
23+
{
24+
::fast_io::timer t(u8"contains");
25+
for (auto const &e : vec)
26+
{
27+
count += static_cast<::std::size_t>(bset.contains(e));
28+
}
29+
}
30+
::fast_io::io::perrln("count=", count);
31+
}
32+
{
33+
::std::size_t total_size{};
34+
{
35+
::fast_io::timer t(u8"iteration");
36+
for (auto const &e : bset)
37+
{
38+
total_size += e.size();
39+
}
40+
}
41+
::fast_io::io::perrln("total_size=", total_size);
42+
}
43+
{
44+
::std::size_t total_size{};
45+
{
46+
::fast_io::timer t(u8"reverse iteration");
47+
for (auto const &e : ::std::ranges::reverse_view(bset))
48+
{
49+
total_size += e.size();
50+
}
51+
}
52+
::fast_io::io::perrln("total_size=", total_size);
53+
}
54+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#pragma once
2+
3+
#include <fast_io_dsal/vector.h>
4+
#include <fast_io_dsal/string.h>
5+
#include <random>
6+
7+
template <typename T = ::fast_io::string>
8+
inline ::fast_io::vector<T> gentest()
9+
{
10+
::fast_io::vector<T> vec;
11+
::std::mt19937_64 eng;
12+
::std::uniform_int_distribution<std::size_t> ud(0, 61);
13+
::std::uniform_int_distribution<std::size_t> rlen(25, 30);
14+
for (::std::size_t i{}; i != 1000000; ++i)
15+
{
16+
T tempstr;
17+
::std::size_t n{rlen(eng)};
18+
tempstr.reserve(n);
19+
for (::std::size_t j{}; j != n; ++j)
20+
{
21+
char8_t ch(static_cast<char8_t>(ud(eng)));
22+
if (ch < 10u)
23+
{
24+
ch += u8'0';
25+
}
26+
else if (ch < 36u)
27+
{
28+
ch = ch - 10u + u8'a';
29+
}
30+
else
31+
{
32+
ch = ch - 36u + u8'A';
33+
}
34+
tempstr.push_back(ch);
35+
}
36+
vec.emplace_back(::std::move(tempstr));
37+
}
38+
return vec;
39+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "rustbtree"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
rand = "0.9.1"
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
use rand::rngs::StdRng;
2+
use rand::{Rng, SeedableRng};
3+
use std::collections::BTreeSet;
4+
use std::time::Instant;
5+
6+
fn generate_test_data() -> Vec<String> {
7+
let mut vec = Vec::with_capacity(1_000_000);
8+
let mut rng = StdRng::seed_from_u64(0xDEADBEEF); // deterministic seed
9+
10+
for _ in 0..1_000_000 {
11+
let len = rng.random_range(25..=30); // replaces Uniform(8, 20)
12+
let mut s = String::with_capacity(len);
13+
14+
for _ in 0..len {
15+
let x = rng.random_range(0..=61); // replaces Uniform(0, 61)
16+
let ch = match x {
17+
x if x < 10 => (b'0' + x as u8) as char,
18+
x if x < 36 => (b'a' + (x - 10) as u8) as char,
19+
_ => (b'A' + (x - 36) as u8) as char,
20+
};
21+
s.push(ch);
22+
}
23+
24+
vec.push(s);
25+
}
26+
27+
vec
28+
}
29+
30+
fn main() {
31+
let vec = generate_test_data();
32+
let start_total = Instant::now();
33+
println!("str_btree_set test started");
34+
35+
let mut bset = BTreeSet::new();
36+
37+
let start_insert = Instant::now();
38+
for s in &vec {
39+
bset.insert(s.clone()); // cloning to move into BTreeSet
40+
}
41+
println!("insert_key: {:.2?}", start_insert.elapsed());
42+
43+
let mut count = 0;
44+
let start_contains = Instant::now();
45+
for s in &vec {
46+
if bset.contains(s) {
47+
count += 1;
48+
}
49+
}
50+
println!("contains: {:.2?}", start_contains.elapsed());
51+
// 🚀 Forward iteration benchmark
52+
let mut total_size = 0;
53+
let start_iter = Instant::now();
54+
for s in &bset {
55+
total_size += s.len();
56+
}
57+
println!(
58+
"forward iteration total_size = {}, elapsed: {:.2?}",
59+
total_size,
60+
start_iter.elapsed()
61+
);
62+
63+
// 🔄 Reverse iteration benchmark
64+
let mut total_size = 0;
65+
let start_rev_iter = Instant::now();
66+
for s in bset.iter().rev() {
67+
total_size += s.len();
68+
}
69+
println!(
70+
"reverse iteration total_size = {}, elapsed: {:.2?}",
71+
total_size,
72+
start_rev_iter.elapsed()
73+
);
74+
75+
println!("count = {}", count);
76+
println!("total time: {:.2?}", start_total.elapsed());
77+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include <set>
2+
#include <string>
3+
#include <fast_io.h>
4+
#include <fast_io_driver/timer.h>
5+
#include "gentest.h"
6+
7+
int main()
8+
{
9+
auto vec{::gentest<::std::string>()};
10+
::fast_io::timer t(u8"str_btree_set");
11+
::std::set<typename decltype(vec)::value_type> bset;
12+
{
13+
::fast_io::timer t(u8"insert");
14+
for (auto const &e : vec)
15+
{
16+
bset.insert(e);
17+
}
18+
}
19+
{
20+
::std::size_t count{};
21+
{
22+
::fast_io::timer t(u8"contains");
23+
for (auto const &e : vec)
24+
{
25+
count += static_cast<::std::size_t>(bset.contains(e));
26+
}
27+
}
28+
::fast_io::io::perrln("count=", count);
29+
}
30+
{
31+
::std::size_t total_size{};
32+
{
33+
::fast_io::timer t(u8"iteration");
34+
for (auto const &e : bset)
35+
{
36+
total_size += e.size();
37+
}
38+
}
39+
::fast_io::io::perrln("total_size=", total_size);
40+
}
41+
{
42+
::std::size_t total_size{};
43+
{
44+
::fast_io::timer t(u8"reverse iteration");
45+
for (auto const &e : ::std::ranges::reverse_view(bset))
46+
{
47+
total_size += e.size();
48+
}
49+
}
50+
::fast_io::io::perrln("total_size=", total_size);
51+
}
52+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include <set>
2+
#include <string>
3+
#include <fast_io.h>
4+
#include <fast_io_driver/timer.h>
5+
#include "gentest.h"
6+
7+
int main()
8+
{
9+
auto vec{::gentest()};
10+
::fast_io::timer t(u8"str_btree_set");
11+
::std::set<::fast_io::string> bset;
12+
{
13+
::fast_io::timer t(u8"insert");
14+
for (auto const &e : vec)
15+
{
16+
bset.insert(e);
17+
}
18+
}
19+
{
20+
::std::size_t count{};
21+
{
22+
::fast_io::timer t(u8"contains");
23+
for (auto const &e : vec)
24+
{
25+
count += static_cast<::std::size_t>(bset.contains(e));
26+
}
27+
}
28+
::fast_io::io::perrln("count=", count);
29+
}
30+
{
31+
::std::size_t total_size{};
32+
{
33+
::fast_io::timer t(u8"iteration");
34+
for (auto const &e : bset)
35+
{
36+
total_size += e.size();
37+
}
38+
}
39+
::fast_io::io::perrln("total_size=", total_size);
40+
}
41+
{
42+
::std::size_t total_size{};
43+
{
44+
::fast_io::timer t(u8"reverse iteration");
45+
for (auto const &e : ::std::ranges::reverse_view(bset))
46+
{
47+
total_size += e.size();
48+
}
49+
}
50+
::fast_io::io::perrln("total_size=", total_size);
51+
}
52+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <unordered_set>
2+
#include <string>
3+
#include <fast_io.h>
4+
#include <fast_io_driver/timer.h>
5+
#include "gentest.h"
6+
7+
int main()
8+
{
9+
auto vec{::gentest<std::string>()};
10+
::fast_io::timer t(u8"str_btree_set");
11+
::std::unordered_set<::std::string> bset;
12+
{
13+
::fast_io::timer t(u8"insert");
14+
for (auto const &e : vec)
15+
{
16+
bset.insert(e);
17+
}
18+
}
19+
{
20+
::std::size_t count{};
21+
{
22+
::fast_io::timer t(u8"contains");
23+
for (auto const &e : vec)
24+
{
25+
count += static_cast<::std::size_t>(bset.contains(e));
26+
}
27+
}
28+
::fast_io::io::perrln("count=", count);
29+
}
30+
}

0 commit comments

Comments
 (0)