Skip to content

Instantly share code, notes, and snippets.

View stepancheg's full-sized avatar

Stepan Koltsov stepancheg

View GitHub Profile
/* strcmp with SSE4.2
Copyright (C) 2009 Free Software Foundation, Inc.
Contributed by Intel Corporation.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
%define EQUAL_EACH 1000b
%define NEGATIVE_POLARITY 010000b
EXPORT __strcmp_sse42
mov rax, rdi
sub rax, rsi ; rax = rdi - rsi
sub rsi, 16
@B:
add rsi, 16
#include <stdio.h>
#include <sys/time.h>
#include <stdlib.h>
#include <stdint.h>
const uint64_t count = 1000 * 1000 * 1000;
static uint64_t microseconds() {
struct timeval tv;
if (0 != gettimeofday(&tv, NULL))
@stepancheg
stepancheg / main.java
Created January 8, 2010 03:28
HashMap vs. IdentityHashMap
import java.util.*;
class Main {
private static final Random random = new Random();
static class A {
} /// end of A
static class B {
private final int hashCode = random.nextInt();
Index: build.xml
===================================================================
--- build.xml (revision 20173)
+++ build.xml (working copy)
@@ -5,6 +5,47 @@
<description>
SuperSabbus for Scala core, builds the scala library and compiler. It can also package it as a simple distribution, tests it for stable bootstrapping and against the Scala test suite.
</description>
+
+ <target name="getjar-helper2" unless="skip.download">
<target name="getjar-helper2" unless="skip.download">
<echo>Getting ${url} to ${file}</echo>
</target>
<target name="getjar-helper">
<available property="skip.download" file="${file}"/>
<antcall target="getjar-helper2"/>
</target>
<macrodef name="getjar">
@stepancheg
stepancheg / arrays-sort.scala
Created November 23, 2009 17:37
Arrays.sort
def sort(a: Array[Int]) = {
java.util.Arrays.sort(a)
}
def profile[T](what: String)(action: => T) = {
val start = System.currentTimeMillis()
val r = action
val delta = System.currentTimeMillis() - start
println(what + ": " + delta + "; " + r)
}
@stepancheg
stepancheg / sort.cpp
Created November 23, 2009 17:27
sort.cpp
#include <sys/time.h>
#include <time.h>
#include <stdlib.h>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
@stepancheg
stepancheg / 20m.scala
Created November 23, 2009 17:15
Collections.sort
case class A(value: Int)
def sort(a: java.util.List[A]) = {
val c = new java.util.Comparator[A] {
override def compare(x: A, y: A) = x.value - y.value
}
java.util.Collections.sort(a, c)
}
def profile[T](what: String)(action: => T) = {
def profile[T](what: String)(action: => T) = {
val start = System.currentTimeMillis()
val r = action
val delta = System.currentTimeMillis() - start
println(what + ": " + delta + "; " + r)
}