Skip to content

Instantly share code, notes, and snippets.

View gaul's full-sized avatar

Andrew Gaul gaul

View GitHub Profile
import os
import threading
NUM_THREADS = 8
FILE_SIZE = 4 * 1024 * 1024 * 1024
BLOCK_SIZE = 1024 * 1024
BLOCK = b'\0' * BLOCK_SIZE
def worker(fd, offset, length):
for i in range(offset, offset + length, BLOCK_SIZE):
[ec2-user@ip-172-31-0-156 ~]$ ~/go/src/github.com/kahing/goofys/bench/bench.sh "$HOME/s3fs-fuse/src/s3fs gaultest-us-west-1b $HOME/mnt -o use_path_request_style -o url=https://s3-us-west-1.amazonaws.com -o endpoint=us-west-1 -ostat_cache_expire=1" ~/mnt
create_files 7.834
rm_files 2.093
create_files 10.415
rm_files 2.119
create_files 10.136
rm_files 2.192
create_files 9.773
rm_files 1.932
create_files 9.103
#!/bin/env/python3
class CircularBuffer:
def __init__(self, capacity):
self.array = [None] * capacity
self.used = 0
self.index = 0
def push(self, elem):
if self.used == len(self.array):
### Keybase proof
I hereby claim:
* I am gaul on github.
* I am gaul (https://keybase.io/gaul) on keybase.
* I have a public key ASCAEBCgIFZcqRtP-nQ-4e5w06M4DyIenIzaXdSizH56TAo
To claim this, I am signing this object:
$ mvn clean test-compile -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Apache jclouds Project
[INFO] jclouds shared Maven resources
[INFO] jclouds Components Core
[INFO] jclouds SLF4J Logging Module
@gaul
gaul / PrimitiveOverhead.java
Created May 20, 2014 17:10
Demonstrate overhead of primitives stored in an object
/**
* Demonstrate overhead of primitives stored in an object. Note that each
* object has 12 bytes of overhead for the class pointer, flags, and monitor and
* the JVM pads each object to the next 8 byte alignment. Thus an object with
* two byte fields will consume 16 bytes and an object with two int fields will
* consume 24 bytes:
*
* $ javac PrimitiveOverhead.java ; java PrimitiveOverhead
*
* num #instances #bytes class name
@gaul
gaul / naughty.c
Created January 29, 2014 19:31
run a program with soft real-time priority
/*
* naughty - run a program with soft real-time priority. naughty may reduce
* clock skew when benchmarking not quite idle systems. Tested on Linux
* 2.4.22. This program has been placed in the public domain. Written by
* Andrew Gaul <andrew@gaul.org>. Last modified 2 March 2004.
*/
/* XXX watchdog to kill runaway process */
#include <sched.h>
@gaul
gaul / MapFilterTest.java
Created October 31, 2013 20:45
Demonstrate mapping and filtering using Java 7, Guava, and Java 8 constructs.
/**
* Demonstrate mapping and filtering using Java 7, Guava, and Java 8 constructs.
*
* Test with:
* javac -cp .:$HOME/.m2/repository/com/google/guava/guava/15.0/guava-15.0.jar MapFilterTest.java
*/
import java.util.Collection;
import java.util.Iterator;
@gaul
gaul / gist:6999997
Last active December 25, 2015 15:39
Demonstrate how to write a single iterator which calls jclouds BlobStore.list until it lists all blobs.
public class PageSetIterableTest {
private class PageSetIterable implements Iterator<StorageMetadata> {
private final String container;
private ListContainerOptions options;
private PageSet<? extends StorageMetadata> set;
private Iterator<? extends StorageMetadata> iterator;
private PageSetIterable(String container, ListContainerOptions options) {
this.container = checkNotNull(container);
advanceList(options);
@gaul
gaul / CloserTest.java
Last active December 22, 2015 07:59
Test Closer behavior with Java 6 and 7.
import java.io.Closeable;
import java.io.IOException;
import com.google.common.io.Closer;
public class CloserTest {
private static void testCloserJava6() throws Exception {
Closer closer = Closer.create();
try {
Closeable closeable = closer.register(