Skip to content

Instantly share code, notes, and snippets.

View jonathan-beard's full-sized avatar
💭
available

Jonathan Beard jonathan-beard

💭
available
View GitHub Profile
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <time.h>
int
main( int argc, char **argv )
{
struct timespec curr_time;
std::memset( &curr_time,
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <mach/mach.h>
#include <mach/mach_time.h>
int
main( int argc, char **argv )
{
auto curr_time( mach_absolute_time() );
/**
* pin the current thread
*/
cpu_set_t *cpuset( nullptr );
size_t cpu_allocate_size( -1 );
#if (__GLIBC_MINOR__ > 9 ) && (__GLIBC__ == 2 )
const int8_t processors_to_allocate( 1 );
cpuset = CPU_ALLOC( processors_to_allocate );
assert( cpuset != nullptr );
cpu_allocate_size = CPU_ALLOC_SIZE( processors_to_allocate );
std::uint64_t cycles( 0 );
/** begin assembly section to init previous **/
#ifdef __x86_64
__asm__ volatile(
#if RDTSCP
"\
rdtscp \n\
shl $32, %%rdx \n\
orq %%rax, %%rdx \n\
movq %%rdx, %[cyc]"
@jonathan-beard
jonathan-beard / findleaks.pl
Last active August 29, 2015 14:04
Stupid simple script to get leaks on programs running on OS X...doesn't quite parse the output of ps -A correctly but I don't have time to fix right now and it works well enough to be used.
#!/usr/bin/env perl
use strict;
use warnings;
##
# getProcessList - returns an array of an arrays
# first index is the pid, second the executable
# it refers to
##
sub getProcessList();
@jonathan-beard
jonathan-beard / joinpdf
Created January 9, 2015 02:23
Stupid simple wrapper around ghostscript to join pdf's, I didn't feel like typing it over and over........
#!/usr/bin/env perl
use strict;
use warnings;
##
# Stupid simple wrapper around ghostscript to join pdf's
##
##
# check for args < 2, just assume
/* vim: set shiftwidth=3 set tabstop=3 set number set ai set aw set expandtab : */
/* you need to have 'set modeline' within your vimrc for the above to work */
#include <cstdint>
#include <iostream>
#include <cstdlib>
struct foo <% std::int32_t k; %>;
static std::int32_t count = 0;
#include <iostream>
#include <cstdlib>
#include <cstdlib>
#include <sys/mman.h>
#include <unistd.h>
#include <iomanip>
int
main( int argc, char **argv )
{
#include <iostream>
#include <cstdlib>
/**
* low level programming question, exp. C/C++ programmer
* should know:
* How are struct and ptr related? How is this
* different if all the named variables in the struct
* are homogeneous in type? How about when the struct
* has many types?
*/
#include <iostream>
#include <iomanip>
#include <cstdlib>
/** try with -O0 then -O3 **/
struct foo
{
/**
* remember, this should be undetermined....
* never leave a class var like this