Skip to content

Instantly share code, notes, and snippets.

View corobench.cc
/* link with liblwan and google benchmark */
#include <stdbool.h>
#include <stdio.h>
#include <benchmark/benchmark.h>
extern "C" {
#include <lwan-coro.h>
}
struct coro *coro;
View co.c
#include <stdio.h>
#include <stdbool.h>
struct coro {
void *state;
};
struct range_coro {
struct coro base;
int cur, max, step;
View crcbench.cpp
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <benchmark/benchmark.h>
unsigned int odd_constant = 0xdeadbeef | 1;
static unsigned int hash_crc32_orig(const void *keyptr)
{
unsigned int hash = odd_constant;
View comefrom.diff
Index: include/clang/AST/RecursiveASTVisitor.h
===================================================================
--- include/clang/AST/RecursiveASTVisitor.h (revision 315357)
+++ include/clang/AST/RecursiveASTVisitor.h (working copy)
@@ -2147,6 +2147,7 @@
DEF_TRAVERSE_STMT(DoStmt, {})
DEF_TRAVERSE_STMT(ForStmt, {})
DEF_TRAVERSE_STMT(GotoStmt, {})
+DEF_TRAVERSE_STMT(ComeFromStmt, {})
DEF_TRAVERSE_STMT(IfStmt, {})
View gist:4e09f5a038b740d61860488679427c4e
/* Build with google benchmark */
#include "benchmark/benchmark.h"
#include <ctype.h>
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
View keyboardmouse.ino
/* Based on code by user DorianRudolph on GitHub
https://gist.github.com/DorianRudolph/ca283dfdfd185bc812b7
*/
/*
TODO:
- use menu key as a Fn key to enable multimedia control
- Fn+F1 = toggle mute
- Fn+F2 = vol up
- Fn+F3 = vol dn
@lpereira
lpereira / surface.cpp
Last active Apr 4, 2017
surface.go from chapter 3 of "The Go Programming Language"
View surface.cpp
namespace io {
struct Reader {
virtual std::tuple<int, moku::error> Read(moku::slice<uint8_t> p) = 0;
};
struct Writer {
virtual std::tuple<int, moku::error> Write(moku::slice<uint8_t> p) = 0;
};
} // namespace io
namespace fmt {
moku::error Errorf(std::string format, moku::slice<moku::empty_interface> a);
View results.txt
% sudo cpupower frequency-set -g performance ~/git/benchmark/build
Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3
% ./test ~/git/simdswitch
Run on (4 X 2746.51 MHz CPU s)
2017-01-06 08:06:24
Benchmark Time CPU Iterations
@lpereira
lpereira / bbshield.go
Last active Dec 18, 2016
Buildbot shield generator
View bbshield.go
/*
* Buildbot 0.9.x shield generator
* Copyright (c) 2016 Leandro Pereira <leandro@tia.mat.br>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in the
* Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the
* following conditions:
@lpereira
lpereira / tpl-array.c
Created Nov 3, 2016
Lwan template with arrays
View tpl-array.c
#include <lwan.h>
#include <lwan-template.h>
#include <strbuf.h>
struct thing {
lwan_tpl_list_generator_t generator;
const char *name;
};
You can’t perform that action at this time.