This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <atomic> | |
#include <chrono> | |
#include <iostream> | |
#include <random> | |
using namespace std::chrono_literals; | |
static __inline__ uint64_t rdtsc() { | |
uint64_t hi, lo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <functional> | |
#include <iostream> | |
#include <string> | |
template <typename... Fs> class Overload; | |
template <typename F> | |
class Overload<F> { | |
F _f; | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is an example program to demonstrate false sharing between threads. | |
* | |
* It can be compiled two ways: | |
* gcc -g false_sharing.c -Wall -pthread -lnuma -o false_sharing | |
* gcc -g false_sharing.c -Wall -pthread -lnuma -DNO_FALSE_SHARING -o no_false_sharing | |
* | |
* The -DNO_FALSE_SHARING macro reduces the false sharing. | |
* | |
* The usage is: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <errno.h> | |
#include "spec.h" | |
static jmp_buf buf; | |
void | |
do_run_test(testfunc test, const char *name, int position, int count) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <iostream> | |
#include <numeric> | |
#include <sstream> | |
#include <string> | |
#include <boost/filesystem.hpp> | |
#include <sys/stat.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
/* | |
* bitAnd - x&y using only ~ and | | |
* Example: bitAnd(6, 5) = 4 | |
* Legal ops: ~ | | |
* Max ops: 8 | |
* Rating: 1 | |
*/ | |
int bitAnd(int x, int y) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.atomic.AtomicInteger; | |
import java.util.concurrent.atomic.AtomicReference; | |
public final class Combiner { | |
public interface Action { | |
public void apply(); | |
} | |
private static final class Node { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HungVm { | |
public static void main(String[] argc) throws InterruptedException { | |
for (int i = 0; i < 100000; ++i) { | |
countOdds(10); | |
} | |
Thread t = new Thread(() -> { | |
long l = countOdds(Integer.MAX_VALUE); | |
System.out.println("How Odd:" + l); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns pixr | |
(:import [java.io File] | |
[java.nio.file Files FileSystems LinkOption Path StandardCopyOption] | |
[java.time LocalDateTime ZoneOffset] | |
[java.time.temporal ChronoField] | |
[java.util.concurrent TimeUnit])) | |
(defn niopath [path] | |
(.getPath (FileSystems/getDefault) path (into-array String []))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.Map as Map | |
import Data.List | |
import Data.List.Split | |
import Data.Monoid | |
import Control.Applicative | |
import System.Environment | |
import System.Directory | |
import System.IO | |
--module Main where |