Skip to content

Instantly share code, notes, and snippets.

Diego Pino dpino

View GitHub Profile
@dpino
dpino / v8-test.pl
Last active Aug 29, 2015
Helper script for running V8 tests
View v8-test.pl
#!/usr/bin/perl
use strict;
my $V8_PATH=undef; # Absolute path to your V8 folder
my $RUN_TEST="tools/run-tests.py";
my $ARCH_AND_MODE="x64.release";
if (!$V8_PATH || scalar(@ARGV) != 1) {
help();
@dpino
dpino / snabb-basic.lua
Last active Aug 29, 2015
Snabb basic app
View snabb-basic.lua
#!/usr/bin/env snabb
-- Run as: sudo ./snabb snsh snabb-basic.lua
--
-- Source: https://github.com/dverbeir/snabbswitch/blob/2bfec54a55146f36aa0e988b90c58ce110df6522/src/designs/dv/fwd
local config = require("core.config")
local app = require("core.app")
local link = require("core.link")
@dpino
dpino / perf-iterators.lua
Last active Aug 29, 2015
Measures performance of loops iterating with pairs, ipairs and indexing
View perf-iterators.lua
#!/usr/bin/env luajit
--[[
Environment: Lenovo ThinkPad X200 / 16GB RAM / iCore7 2620M (2.70GHz, 4MB Cache)
| pairs | ipairs | indexing |
| 1.000000 | 5.244480 | 9.388388 |
| 0.190677 | 1.000000 | 1.790146 |
| 0.106515 | 0.558614 | 1.000000 |
@dpino
dpino / lj-bcname.lua
Last active Aug 29, 2015
Queries Luajit bytecode mnemonic by index or name
View lj-bcname.lua
#!/usr/bin/env luajit
-- Prints out LuaJIT bytecode (name, number), by number or name.
--
-- usage: lj-bcname <bc_name|bc_number>...
--
-- example:
--
-- $ luajit-2.1 lj-bcname UCOL
-- UCOL (51)
@dpino
dpino / gist:61b06a6b03a71070906a
Created Dec 10, 2014
v8-issue-553623004. Crash while building.
View gist:61b06a6b03a71070906a
From 453bae509cece509a70157b66ab2b5a62bd21deb Mon Sep 17 00:00:00 2001
From: Diego Pino Garcia <dpino@igalia.com>
Date: Wed, 10 Dec 2014 15:59:09 +0100
Subject: [PATCH] Redefine ToLengthFlagged
---
src/array.js | 5 +++--
src/harmony-array.js | 2 ++
2 files changed, 5 insertions(+), 2 deletions(-)
@dpino
dpino / snabb-create-app.lua
Last active Aug 29, 2015
Create basic Snabb Switch app
View snabb-create-app.lua
#!/usr/bin/env luajit
local main_template = [=[
local config = require("core.config")
local app = require("core.app")
local link = require("core.link")
local pcap = require("apps.pcap.pcap")
local <?= app_name ?> = require("<?= basename ?>.<?= app_name ?>")
View snabb-basic-2.lua
local Intel82599 = require("apps.intel.intel_app").Intel82599
local app = require("core.app")
local basic_apps = require("apps.basic.basic_apps")
local config = require("core.config")
local lib = require("core.lib")
local link = require("core.link")
local C = require("ffi").C
function mq_sq (pcidevA, pcidevB)
@dpino
dpino / source_nic_sink_2.lua
Last active Aug 29, 2015
source_nic_sink_2.lua
View source_nic_sink_2.lua
-- Source -> NIC -> Sink
--
-- Execute in "chur":
-- sudo ./snabb snsh source_nic_sink_2.lua
--
-- link report:
-- 0 sent on nic1.tx -> sink.in1 (loss rate: 0%)
-- 4,319,072 sent on nic2.tx -> sink.in2 (loss rate: 0%)
-- 8,604,975 sent on repeater_ms.output -> nic1.rx (loss rate: 0%)
-- 1 sent on source_ms.out -> repeater_ms.input (loss rate: 0%)
@dpino
dpino / source_nic_sink_3.lua
Last active Aug 29, 2015
source_nic_sink_3.lua
View source_nic_sink_3.lua
-- Source -> NIC1 -> NIC2 -> Sink
-- How to run:
-- sudo ./snabb snsh source_nic_sink_3.lua
-- The NIC is connected in loop back mode.
-- link report:
-- 9,169,796 sent on nic2.tx -> sink.in1 (loss rate: 0%)
-- 9,237,861 sent on repeater_ms.output -> nic1.rx (loss rate: 0%)
@dpino
dpino / bitwise.lua
Created Nov 2, 2015
Bitwise operator module for Lua in plain Lua
View bitwise.lua
local MAX = 64
function tobit(n)
local ret = {}
for i=MAX-1,0,-1 do
if n / 2^i >= 1 then
ret[i+1] = 1
n = n % 2^i
else
ret[i+1] = 0
You can’t perform that action at this time.