Tweaking
This commit is contained in:
parent
c2913d5d69
commit
beb030fc16
|
@ -21,7 +21,7 @@ bool is_ok = json_parse(p, pj); // do the parsing, return false on error
|
||||||
```
|
```
|
||||||
|
|
||||||
It is also possible to use a simply API if you do not mind having the overhead
|
It is also possible to use a simply API if you do not mind having the overhead
|
||||||
of memory allocation:
|
of memory allocation with each new JSON document:
|
||||||
|
|
||||||
```C
|
```C
|
||||||
#include "simdjson/jsonparser.h"
|
#include "simdjson/jsonparser.h"
|
||||||
|
@ -36,8 +36,6 @@ if( ! pj.isValid() ) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
ParsedJson build_parsed_json(const std::string_view &s)
|
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
@ -60,7 +58,7 @@ make parse
|
||||||
|
|
||||||
To run comparative benchmarks (with other parsers):
|
To run comparative benchmarks (with other parsers):
|
||||||
```
|
```
|
||||||
make parse
|
make parsingcompetition
|
||||||
./parsingcompetition jsonexamples/twitter.json
|
./parsingcompetition jsonexamples/twitter.json
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -88,8 +88,9 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
int repeat = 10;
|
int repeat = 10;
|
||||||
int volume = p.size();
|
int volume = p.size();
|
||||||
BEST_TIME("simdjson", json_parse(p, pj), true, , repeat, volume, true);
|
BEST_TIME("simdjson (dynamic mem) ", build_parsed_json(p).isValid(), true, , repeat, volume, true);
|
||||||
BEST_TIME("simdjson (with dyn alloc) ", build_parsed_json(p).isValid(), true, , repeat, volume, true);
|
|
||||||
|
BEST_TIME("simdjson (static alloc) ", json_parse(p, pj), true, , repeat, volume, true);
|
||||||
|
|
||||||
rapidjson::Document d;
|
rapidjson::Document d;
|
||||||
|
|
||||||
|
@ -123,3 +124,4 @@ int main(int argc, char *argv[]) {
|
||||||
free(ast_buffer);
|
free(ast_buffer);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,14 +51,7 @@ public:
|
||||||
n_structural_indexes = 0;
|
n_structural_indexes = 0;
|
||||||
u32 max_structures = ROUNDUP_N(len, 64) + 2 + 7;
|
u32 max_structures = ROUNDUP_N(len, 64) + 2 + 7;
|
||||||
structural_indexes = new u32[max_structures];
|
structural_indexes = new u32[max_structures];
|
||||||
|
size_t localtapecapacity = ROUNDUP_N(len / 2, 64);
|
||||||
if (structural_indexes == NULL) {
|
|
||||||
std::cerr << "Could not allocate memory for structural_indexes"
|
|
||||||
<< std::endl;
|
|
||||||
delete[] structurals;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
size_t localtapecapacity = ROUNDUP_N(len, 64);
|
|
||||||
size_t localstringcapacity = ROUNDUP_N(len, 64);
|
size_t localstringcapacity = ROUNDUP_N(len, 64);
|
||||||
string_buf = new u8[localstringcapacity];
|
string_buf = new u8[localstringcapacity];
|
||||||
tape = new u64[localtapecapacity];
|
tape = new u64[localtapecapacity];
|
||||||
|
@ -66,14 +59,14 @@ public:
|
||||||
ret_address = new void *[maxdepth];
|
ret_address = new void *[maxdepth];
|
||||||
|
|
||||||
if ((string_buf == NULL) || (tape == NULL) ||
|
if ((string_buf == NULL) || (tape == NULL) ||
|
||||||
(containing_scope_offset == NULL) || (ret_address == NULL)) {
|
(containing_scope_offset == NULL) || (ret_address == NULL) || (structural_indexes == NULL)) {
|
||||||
std::cerr << "Could not allocate memory" << std::endl;
|
std::cerr << "Could not allocate memory" << std::endl;
|
||||||
delete[] ret_address;
|
delete[] ret_address;
|
||||||
delete[] containing_scope_offset;
|
delete[] containing_scope_offset;
|
||||||
delete[] tape;
|
delete[] tape;
|
||||||
delete[] string_buf;
|
delete[] string_buf;
|
||||||
delete[] structural_indexes;
|
delete[] structural_indexes;
|
||||||
delete[] structurals;
|
free(structurals);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue