-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathtest.cpp
70 lines (54 loc) · 1.94 KB
/
test.cpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <Rcpp.h>
#include <RProgress.h>
#include <unistd.h>
// [[Rcpp::export]]
Rcpp::CharacterVector test_progress(Rcpp::CharacterVector formatSEXP =
"[:bar] :percent ") {
BEGIN_RCPP
const char *format = formatSEXP[0];
RProgress::RProgress pb(format);
pb.tick(0);
for (int i = 0; i < 100; i++) {
usleep( (useconds_t) (2.0 / 100 * 1000000));
pb.tick();
}
Rcpp::CharacterVector result(1);
result[0] = "DONE";
return result;
END_RCPP
}
// [[Rcpp::export]]
Rcpp::LogicalVector test_is_option_enabled() {
BEGIN_RCPP
Rcpp::LogicalVector result(1);
result[0] = RProgress::RProgress::is_option_enabled();
return result;
END_RCPP
}
// [[Rcpp::export]]
Rcpp::CharacterVector test_units() {
BEGIN_RCPP
Rcpp::CharacterVector result(20);
result[0] = RProgress::RProgress::vague_dt(0);
result[1] = RProgress::RProgress::vague_dt(1);
result[2] = RProgress::RProgress::vague_dt(1.1);
result[3] = RProgress::RProgress::vague_dt(51);
result[4] = RProgress::RProgress::vague_dt(2 * 60);
result[5] = RProgress::RProgress::vague_dt(3 * 60 * 60);
result[6] = RProgress::RProgress::vague_dt(3 * 60 * 60 * 24);
result[7] = RProgress::RProgress::vague_dt(31 * 60 * 60 * 24);
result[8] = RProgress::RProgress::vague_dt(400 * 60 * 60 * 24);
result[9] = RProgress::RProgress::vague_dt(1500 * 60 * 60 * 24);
result[10] = RProgress::RProgress::pretty_bytes(0);
result[11] = RProgress::RProgress::pretty_bytes(133);
result[12] = RProgress::RProgress::pretty_bytes(1337);
result[13] = RProgress::RProgress::pretty_bytes(13337);
result[14] = RProgress::RProgress::pretty_bytes(133337);
result[15] = RProgress::RProgress::pretty_bytes(1333337);
result[16] = RProgress::RProgress::pretty_bytes(13333337);
result[17] = RProgress::RProgress::pretty_bytes(133333337);
result[18] = RProgress::RProgress::pretty_bytes(1333333337);
result[19] = RProgress::RProgress::pretty_bytes(1333333337);
return result;
END_RCPP
}