Skip to content

Instantly share code, notes, and snippets.

View miloyip's full-sized avatar

Milo Yip miloyip

  • Tencent
  • Hong Kong, China
View GitHub Profile
Before removing setjmp():
[==========] Running 17 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 17 tests from RapidJson
[ RUN ] RapidJson.ReaderParseInsitu_DummyHandler_SSE42
[ OK ] RapidJson.ReaderParseInsitu_DummyHandler_SSE42 (674 ms)
[ RUN ] RapidJson.ReaderParseInsitu_DummyHandler_ValidateEncoding_SSE42
[ OK ] RapidJson.ReaderParseInsitu_DummyHandler_ValidateEncoding_SSE42 (12
72 ms)
Before:
[==========] Running 17 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 17 tests from RapidJson
[ RUN ] RapidJson.ReaderParseInsitu_DummyHandler_SSE42
[ OK ] RapidJson.ReaderParseInsitu_DummyHandler_SSE42 (704 ms)
[ RUN ] RapidJson.ReaderParseInsitu_DummyHandler_ValidateEncoding_SSE42
[ OK ] RapidJson.ReaderParseInsitu_DummyHandler_ValidateEncoding_SSE42 (12
74 ms)
[ RUN ] RapidJson.ReaderParse_DummyHandler_SSE42
@miloyip
miloyip / Termination
Last active August 29, 2015 14:03
Performance comparison after adding termination function from handler.
Macbook Air
Before
[==========] Running 17 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 17 tests from RapidJson
[ RUN ] RapidJson.ReaderParseInsitu_DummyHandler
[ OK ] RapidJson.ReaderParseInsitu_DummyHandler (1100 ms)
[ RUN ] RapidJson.ReaderParseInsitu_DummyHandler_ValidateEncoding
[ OK ] RapidJson.ReaderParseInsitu_DummyHandler_ValidateEncoding (1645 ms)
@miloyip
miloyip / after.txt
Last active August 29, 2015 14:04
Use branchlut for Writer
VC2013 x64
Note: Google Test filter = RapidJson.*
[==========] Running 17 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 17 tests from RapidJson
[ RUN ] RapidJson.ReaderParseInsitu_DummyHandler_SSE42
[ OK ] RapidJson.ReaderParseInsitu_DummyHandler_SSE42 (677 ms)
[ RUN ] RapidJson.ReaderParseInsitu_DummyHandler_ValidateEncoding_SSE42
[ OK ] RapidJson.ReaderParseInsitu_DummyHandler_ValidateEncoding_SSE42 (12
@miloyip
miloyip / gist:9dacf2d4c44c1b301657
Created July 24, 2014 17:17
Strange performance difference betweeb Iterative and IterativeInsitu
[ RUN ] RapidJson.ReaderParseInsitu_DummyHandler_SSE42
[ OK ] RapidJson.ReaderParseInsitu_DummyHandler_SSE42 (726 ms)
[ RUN ] RapidJson.ReaderParseInsitu_DummyHandler_ValidateEncoding_SSE42
[ OK ] RapidJson.ReaderParseInsitu_DummyHandler_ValidateEncoding_SSE42 (1260 ms)
[ RUN ] RapidJson.ReaderParse_DummyHandler_SSE42
[ OK ] RapidJson.ReaderParse_DummyHandler_SSE42 (1147 ms)
[ RUN ] RapidJson.ReaderParseIterative_DummyHandler_SSE42
[ OK ] RapidJson.ReaderParseIterative_DummyHandler_SSE42 (1247 ms)
[ RUN ] RapidJson.ReaderParseIterativeInsitu_DummyHandler_SSE42
[ OK ] RapidJson.ReaderParseIterativeInsitu_DummyHandler_SSE42 (647 ms)
@miloyip
miloyip / gist:2340dafc7ec779ffea5e
Last active August 29, 2015 14:05
dtoa optimization
VC2013 x64 Before
[ OK ] RapidJson.ReaderParseIterativeInsitu_DummyHandler_SSE42 (663 ms)
[ OK ] RapidJson.Writer_NullStream (325 ms)
[ OK ] RapidJson.Writer_StringBuffer (1020 ms)
[ OK ] RapidJson.PrettyWriter_StringBuffer (1420 ms)
Cygwin GCC x64 Before
[ OK ] RapidJson.ReaderParseIterativeInsitu_DummyHandler_SSE42 (875 ms)
[ OK ] RapidJson.Writer_NullStream (5201 ms)
[ OK ] RapidJson.Writer_StringBuffer (5673 ms)
@miloyip
miloyip / IsWhitespace_Arithmetic.cpp
Created February 15, 2016 07:10
IsWhitespace_Arithmetic
inline uint32_t IsWhitespace_Arithmetic(char c) {
uint32_t v = (static_cast<uint32_t>(c) * 0x01010101u) ^ 0x200A0D09u;
return (v - 0x01010101u) & ~v & 0x80808080u; // https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord
}
#include "rapidjson/document.h"
#include <iostream>
#include <pthread.h>
void* MyThread(void*)
{
std::cout << "Start of MyThread" << std::endl;
rapidjson::Document doc;
@miloyip
miloyip / isqrt.cpp
Last active November 5, 2019 17:12
Big integer square root
#include <cassert>
#include <iostream>
#include <vector>
#include <type_traits>
// http://www.embedded.com/electronics-blogs/programmer-s-toolbox/4219659/Integer-Square-Roots
uint32_t isqrt0(uint32_t n) {
uint32_t delta = 3;
for (uint32_t square = 1; square <= n; delta += 2)
@miloyip
miloyip / eqdist1.cpp
Last active April 12, 2016 15:30
Equidistance traversal
#include <algorithm>
#include <vector>
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
struct Point {
Point(int x, int y) : x(x), y(y), sqDist(x * x + y * y) {}