Files
strager 5510089d45 Improve build times for debug builds (#1859)
* Rename simdjson_really_inline -> simdjson_inline

I want to change the simdjson_really_inline macro to sometimes not force
inlining. After that upcoming change, the name simdjson_really_inline
will no longer makes sense.

Rename simdjson_really_inline to simdjson_inline. This patch should not
change semantics; simdjson_inline still forces inlining as before.

Some functions still need to be really inlined for ABI reasons.
(GCC's -Wpsabi complains otherwise.) Leave those functions marked as
simdjson_really_inline.

* Improve build times for debug builds

simdjson_inline is used for most simdjson functions. It forces inlining.
In unoptimized/debug builds, this can lead to a lot of machine code
being generated (especially with Address Sanitizer), causing slow
compilation.

Change simdjson_inline to force inlining only for optimized builds.

Sometimes, the programmer might want a slightly-optimized build and want
fast compilation (e.g. GCC's -Og mode). Allow simdjson users to define
the simdjson_inline macro themselves (e.g. on the command line:
-Dsimdjson_inline=inline) in cases where the default behavior is
undesired.

This patch reduced build times by over 75% for ondemand_object_tests.cpp
with GCC 9.4.0 and CMAKE_BUILD_TYPE=Debug on my AMD 5950X:

Before: 6.885 6.683 6.971 6.957 6.949 seconds (5 samples)
After:  1.492 1.551 1.494 1.490 1.531 seconds (5 samples)
2022-07-19 15:14:33 -04:00

62 lines
2.2 KiB
C++

#pragma once
#include "simdjson.h"
#include "twitter_user.h"
namespace partial_tweets {
// {
// "statuses": [
// {
// "created_at": "Sun Aug 31 00:29:15 +0000 2014",
// "id": 505874924095815700,
// "text": "@aym0566x \n\n名前:前田あゆみ\n第一印象:なんか怖っ!\n今の印象:とりあえずキモい。噛み合わない\n好きなところ:ぶすでキモいとこ😋✨✨\n思い出:んーーー、ありすぎ😊❤️\nLINE交換できる?:あぁ……ごめん✋\nトプ画をみて:照れますがな😘✨\n一言:お前は一生もんのダチ💖",
// "in_reply_to_status_id": null,
// "user": {
// "id": 1186275104,
// "screen_name": "ayuu0123"
// },
// "retweet_count": 0,
// "favorite_count": 0
// }
// ]
// }
template<typename StringType=std::string_view>
struct tweet {
StringType created_at{};
uint64_t id{};
StringType result{};
uint64_t in_reply_to_status_id{};
twitter_user<StringType> user{};
uint64_t retweet_count{};
uint64_t favorite_count{};
template<typename OtherStringType>
simdjson_inline bool operator==(const tweet<OtherStringType> &other) const {
return created_at == other.created_at &&
id == other.id &&
result == other.result &&
in_reply_to_status_id == other.in_reply_to_status_id &&
user == other.user &&
retweet_count == other.retweet_count &&
favorite_count == other.favorite_count;
}
template<typename OtherStringType>
simdjson_inline bool operator!=(const tweet<OtherStringType> &other) const { return !(*this == other); }
};
template<typename StringType>
simdjson_unused static std::ostream &operator<<(std::ostream &o, const tweet<StringType> &t) {
o << "created_at: " << t.created_at << std::endl;
o << "id: " << t.id << std::endl;
o << "result: " << t.result << std::endl;
o << "in_reply_to_status_id: " << t.in_reply_to_status_id << std::endl;
o << "user.id: " << t.user.id << std::endl;
o << "user.screen_name: " << t.user.screen_name << std::endl;
o << "retweet_count: " << t.retweet_count << std::endl;
o << "favorite_count: " << t.favorite_count << std::endl;
return o;
}
} // namespace partial_tweets