Skip to content

Instantly share code, notes, and snippets.

View fluency03's full-sized avatar

Chang Liu fluency03

  • London
View GitHub Profile
@fluency03
fluency03 / latency.txt
Created May 22, 2016 17:06 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
#!/usr/bin/env python
#
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
#
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
#
/**
* Class: ListNode
* Author: Chang LIU
*/
package linkedlist;
import static java.lang.System.out;
public class ListNode<T> {
/**
* This is a Scala script: scala-script.scala
*/
println("Hello, World! From a script!")
/**
* This is a Scala script: scala-script-arg.scala
* Say hello to the first argument!
*/
println("Hello, " + args(0) + "!")
/**
* This is a Scala script: scala-if.scala
*/
val a = 1
val b = 2
var result1 = ""
if (a == b) {
/**
* This is a Scala script: scala-while.scala
*/
var num1: Int = 0
while (num1 < 10) {
println("num1 = " + num1);
num1 += 1;
}
/**
* This is a Scala script: scala-for.scala
*/
val xs: Array[Int] = Array(1, 2, 3)
val ys: Array[Int] = Array(1, 2, 3, 4, 5)
/** for comprehension: filter/map */
for (x <- xs if x % 2 == 0)
/**
* This is a Scala script: scala-loop-func.scala
*/
def printArgs1(args: Array[String]): Unit = {
var i = 0
while (i < args.length) {
println(args(i))
i += 1
}