Skip to content

Commit 6eaf061

Browse files
authored
Merge pull request #1265 from trcrsired/next
this module makes me so outraged and stupid. why do you export details functions and other junk? It completely breaks on wasm
2 parents 0a51dcd + 84763e7 commit 6eaf061

23 files changed

Lines changed: 1147 additions & 410 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
["0003.insert_range"]
2+
ignore = true
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <fast_io.h>
2+
#include <fast_io_driver/timer.h>
3+
#include <fast_io_dsal/deque.h>
4+
#include <cstddef>
5+
6+
int main()
7+
{
8+
fast_io::timer tm(u8"fast_io::deque");
9+
fast_io::deque<std::size_t> dq;
10+
constexpr std::size_t n{50000};
11+
12+
{
13+
fast_io::timer t(u8"insert_range_index");
14+
for (std::size_t i{}; i != n; ++i)
15+
{
16+
::std::size_t dqsz{dq.size()};
17+
std::size_t pos = dqsz ? (i % dqsz) : 0;
18+
std::size_t tmp[4]{i, i + 1, i + 2, i + 3};
19+
dq.insert_range_index(pos, tmp);
20+
}
21+
}
22+
23+
std::size_t sum{};
24+
{
25+
fast_io::timer t(u8"loop");
26+
for (auto const e : dq)
27+
{
28+
sum += e;
29+
}
30+
}
31+
32+
fast_io::io::perrln("sum=", sum);
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <fast_io.h>
2+
#include <fast_io_driver/timer.h>
3+
#include <deque>
4+
#include <cstddef>
5+
6+
int main()
7+
{
8+
fast_io::timer tm(u8"std::deque");
9+
::std::deque<std::size_t> dq;
10+
constexpr std::size_t n{50000};
11+
12+
{
13+
fast_io::timer t(u8"insert_range");
14+
for (std::size_t i{}; i != n; ++i)
15+
{
16+
::std::size_t dqsz{dq.size()};
17+
std::size_t pos = dqsz ? (i % dqsz) : 0;
18+
std::size_t tmp[4]{i, i + 1, i + 2, i + 3};
19+
dq.insert_range(dq.cbegin() + pos, tmp);
20+
}
21+
}
22+
23+
std::size_t sum{};
24+
{
25+
fast_io::timer t(u8"loop");
26+
for (auto const e : dq)
27+
{
28+
sum += e;
29+
}
30+
}
31+
32+
fast_io::io::perrln("sum=", sum);
33+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <fast_io.h>
2+
#include <fast_io_driver/timer.h>
3+
#include <fast_io_dsal/deque.h>
4+
5+
int main()
6+
{
7+
::fast_io::timer tm(u8"fast_io::deque");
8+
::fast_io::deque<std::size_t> deq;
9+
constexpr std::size_t n{100000000};
10+
{
11+
::fast_io::timer tm1(u8"push_back");
12+
for (std::size_t i{}; i != n; ++i)
13+
{
14+
deq.push_back(i);
15+
}
16+
}
17+
::std::size_t sum{};
18+
{
19+
::fast_io::timer tm1(u8"indexing loop");
20+
for (::std::size_t i{}, sz{deq.size()}; i != sz; ++i)
21+
{
22+
sum += deq[i];
23+
}
24+
}
25+
::fast_io::io::perrln("sum=", sum);
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <fast_io.h>
2+
#include <fast_io_driver/timer.h>
3+
#include <fast_io_dsal/deque.h>
4+
5+
int main()
6+
{
7+
::fast_io::timer tm(u8"fast_io::deque unchecked");
8+
::fast_io::deque<std::size_t> deq;
9+
constexpr std::size_t n{100000000};
10+
{
11+
::fast_io::timer tm1(u8"push_back");
12+
for (std::size_t i{}; i != n; ++i)
13+
{
14+
deq.push_back(i);
15+
}
16+
}
17+
::std::size_t sum{};
18+
{
19+
::fast_io::timer tm1(u8"indexing unchecked loop");
20+
for (::std::size_t i{}, sz{deq.size()}; i != sz; ++i)
21+
{
22+
sum += deq.index_unchecked(i);
23+
}
24+
}
25+
::fast_io::io::perrln("sum=", sum);
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <fast_io.h>
2+
#include <fast_io_driver/timer.h>
3+
#include <fast_io_dsal/vector.h>
4+
5+
int main()
6+
{
7+
::fast_io::timer tm(u8"fast_io::vector");
8+
::fast_io::vector<std::size_t> vec;
9+
constexpr std::size_t n{100000000};
10+
{
11+
::fast_io::timer tm1(u8"push_back");
12+
for (std::size_t i{}; i != n; ++i)
13+
{
14+
vec.push_back(i);
15+
}
16+
}
17+
::std::size_t sum{};
18+
{
19+
::fast_io::timer tm1(u8"indexing loop");
20+
for (::std::size_t i{}, sz{vec.size()}; i != sz; ++i)
21+
{
22+
sum += vec[i];
23+
}
24+
}
25+
::fast_io::io::perrln("sum=", sum);
26+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <fast_io.h>
2+
#include <fast_io_driver/timer.h>
3+
#include <fast_io_dsal/vector.h>
4+
5+
int main()
6+
{
7+
::fast_io::timer tm(u8"fast_io::vector reserve");
8+
::fast_io::vector<std::size_t> vec;
9+
constexpr std::size_t n{100000000};
10+
vec.reserve(n);
11+
{
12+
fast_io::timer tm1(u8"push_back");
13+
for (std::size_t i{}; i != n; ++i)
14+
{
15+
vec.push_back(i);
16+
}
17+
}
18+
::std::size_t sum{};
19+
{
20+
fast_io::timer tm1(u8"indexing loop");
21+
for (::std::size_t i{}, sz{vec.size()}; i != sz; ++i)
22+
{
23+
sum += vec[i];
24+
}
25+
}
26+
::fast_io::io::perrln("sum=", sum);
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <fast_io.h>
2+
#include <fast_io_driver/timer.h>
3+
#include <fast_io_dsal/vector.h>
4+
5+
int main()
6+
{
7+
::fast_io::timer tm(u8"fast_io::vector unchecked");
8+
::fast_io::vector<std::size_t> vec;
9+
constexpr std::size_t n{100000000};
10+
vec.reserve(n);
11+
{
12+
fast_io::timer tm1(u8"push_back_unchecked");
13+
for (std::size_t i{}; i != n; ++i)
14+
{
15+
vec.push_back_unchecked(i);
16+
}
17+
}
18+
::std::size_t sum{};
19+
{
20+
fast_io::timer tm1(u8"indexing unchecked loop");
21+
for (::std::size_t i{}, sz{vec.size()}; i != sz; ++i)
22+
{
23+
sum += vec.index_unchecked(i);
24+
}
25+
}
26+
::fast_io::io::perrln("sum=", sum);
27+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <fast_io.h>
2+
#include <fast_io_driver/timer.h>
3+
#include <deque>
4+
5+
int main()
6+
{
7+
fast_io::timer tm(u8"std::deque");
8+
::std::deque<std::size_t> deq;
9+
constexpr std::size_t n{100000000};
10+
{
11+
fast_io::timer tm1(u8"push_back");
12+
for (std::size_t i{}; i != n; ++i)
13+
{
14+
deq.push_back(i);
15+
}
16+
}
17+
::std::size_t sum{};
18+
{
19+
fast_io::timer tm1(u8"indexing loop");
20+
for (::std::size_t i{}, sz{deq.size()}; i != sz; ++i)
21+
{
22+
sum += deq[i];
23+
}
24+
}
25+
::fast_io::io::perrln("sum=", sum);
26+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <fast_io.h>
2+
#include <fast_io_driver/timer.h>
3+
#include <fast_io_dsal/deque.h>
4+
#include <algorithm>
5+
#include <random>
6+
7+
int main()
8+
{
9+
constexpr std::size_t n{1000000};
10+
::std::mt19937_64 eng;
11+
::std::uniform_int_distribution<::std::size_t> dis(0, SIZE_MAX);
12+
13+
::fast_io::timer tm(u8"fast_io::deque");
14+
::fast_io::deque<std::size_t> deq;
15+
{
16+
::fast_io::timer tm1(u8"push_back");
17+
for (std::size_t i{}; i != n; ++i)
18+
{
19+
deq.push_back(dis(eng));
20+
}
21+
}
22+
{
23+
::fast_io::timer tm1(u8"sort");
24+
::std::ranges::sort(deq);
25+
}
26+
::std::size_t sum{};
27+
{
28+
::fast_io::timer tm1(u8"loop");
29+
for (auto const &e : deq)
30+
{
31+
sum += e;
32+
}
33+
}
34+
::fast_io::io::perrln("sum=", sum);
35+
}

0 commit comments

Comments
 (0)