-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathstrings.cpp
More file actions
35 lines (25 loc) · 823 Bytes
/
strings.cpp
File metadata and controls
35 lines (25 loc) · 823 Bytes
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
#include "cpp11/strings.hpp"
// Test benchmark for string proxy assignment performance.
// We don't unwind_protect() before each `SET_STRING_ELT()` call,
// as that kills performance.
[[cpp11::register]] cpp11::writable::strings string_proxy_assignment_() {
R_xlen_t size = 100000;
cpp11::writable::strings x(size);
cpp11::r_string elt(NA_STRING);
for (R_xlen_t i = 0; i < size; ++i) {
x[i] = elt;
}
return x;
}
// Test benchmark for string push back performance.
// We don't unwind_protect() before each `SET_STRING_ELT()` call,
// as that kills performance.
[[cpp11::register]] cpp11::writable::strings string_push_back_() {
R_xlen_t size = 100000;
cpp11::writable::strings x;
cpp11::r_string elt(NA_STRING);
for (R_xlen_t i = 0; i < size; ++i) {
x.push_back(elt);
}
return x;
}