Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@primiano
primiano / trace_processor.mermaid
Last active November 9, 2021 11:16
Trace processor ingestion graph
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!doctype html>
<html lang="en-us">
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
<body>
<style>
pre {
border: 1px solid #eee;
margin: 10px 0;
font-family: monospace;
const encoder = new TextEncoder('utf-8');
const decoder = new TextDecoder('utf-8');
const TAG_MASK = 0x3;
const TAG_INT32 = 0;
const TAG_FLOAT64 = 1;
const TAG_STRING = 2;
function encode(cells) {
@primiano
primiano / zip_offsets.py
Last active June 2, 2017 17:46
Dumps offsets of files within a zip file
import zipfile, sys
zip = zipfile.ZipFile(sys.argv[1])
for f in zip.infolist():
# I have no idea about the +2 but observed experimentally that it gets us
# to the right place.
print('%-16x %-10d %s' % (f.header_offset + len(f.FileHeader()) + 2, f.compress_size, f.filename))
@primiano
primiano / 01-another-vector-perftest-using-structs.sh
Created May 30, 2017 12:56
Another vector perftest using structs
$ sudo cpupower frequency-set -g powersave
$ sudo sh -c "echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
$ for cpu in /sys/devices/system/cpu/cpu*; do for p in $(seq 4); do sudo sh -c "echo 1 > $cpu/cpuidle/state$p/disable"; done; do
####################
# Use emplace_back()
####################
$ perf stat out/offlnx/ctest
tcmalloc: large alloc 1600000000 bytes == 0x349af33da000 @
@primiano
primiano / 01-vector-data-vs-operator-square-bracket-vs-push_back-perftests.sh
Last active May 30, 2017 13:10
std::vector data() vs operator[] vs push_back perftests
$ sudo cpupower frequency-set -g powersave
$ sudo sh -c "echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
$ for cpu in /sys/devices/system/cpu/cpu*; do for p in $(seq 4); do sudo sh -c "echo 1 > $cpu/cpuidle/state$p/disable"; done; do
#########################
# F1, use data() directly
#########################
$ perf stat out/offlnx/ctest 1
Performance counter stats for 'out/offlnx/ctest 1':
@primiano
primiano / tracing_macro_constexpr_for_gcc.cc
Last active April 6, 2017 17:00
tracing_macro_constexpr_for_gcc.cc
context: crbug.com/708990
#include <stdint.h>
#include <stdio.h>
#include <string.h>
struct Category {
const char *name;
uint8_t is_enabled;
};
@primiano
primiano / tracing_macros_constexpr.cc
Created April 6, 2017 11:51
tracing_macros_constexpr.cc
#include <stdint.h>
#include <stdio.h>
#include <string.h>
struct Category {
const char *name;
uint8_t is_enabled;
};
constexpr uint32_t N = 100;
#!/bin/bash
PKG="com.chrome.canary"
function write_proc_line {
LINE="$1"
TYPE=$(echo $LINE | cut -d, -f2)
PROC=$(echo $LINE | cut -d, -f3)
PID=$(echo $LINE | cut -d, -f4)
OOM_SCORE=$(adb shell cat /proc/$PID/oom_score)
OOM_ADJ=$(adb shell cat /proc/$PID/oom_adj)