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
go test -bench=. itoa_test.go | |
goos: darwin | |
goarch: amd64 | |
BenchmarkFmtSprintf-4 2000000 938 ns/op | |
BenchmarkStrconvItoa-4 5000000 253 ns/op | |
PASS | |
ok command-line-arguments 4.335s |
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
package floyd | |
import "sync" | |
// FloydTriangle implements the triangle as a slice of slices based on | |
// https://github.com/plutov/practice-go/tree/master/floyd | |
func FloydTriangle(rows int) [][]int { | |
if rows < 0 { | |
panic("can't be less than zero") | |
} |
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
package main | |
import ( | |
"log" | |
"os" | |
) | |
// METHOD1 | |
// Typical Method | |
func GetHostname() 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
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"runtime/pprof" | |
"sync" | |
) |
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
package main | |
import ( | |
"flag" | |
"log" | |
"runtime" | |
"sync" | |
"testing" | |
) |
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 static org.junit.Assert.assertEquals; | |
import org.junit.Test; | |
public class ProgrammaticJUnit { | |
@Test public void test1() { | |
assertEquals(3, 1+2); | |
} | |
@Test public void test2() { | |
assertEquals(8, 3*3); // INTENTIONAL FAIL | |
} |
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
package main | |
import ( | |
"flag" | |
"fmt" | |
"testing" | |
) | |
func Test1(t *testing.T) { | |
if 1+2 != 3 { |
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.ArrayList; | |
import java.util.Iterator; | |
public class ForEach { | |
public ForEach() { | |
} | |
public static void main(String[] var0) { | |
ArrayList var1 = new ArrayList(); | |
Iterator var2 = var1.iterator(); |
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.Stack; | |
public class StackedQuicksort { | |
public static void sort(Comparable<?>[] data, int left, int right) { | |
Stack<Integer> stack = new Stack<>(); | |
stack.push(left); | |
stack.push(right); | |
while (!stack.empty()) { | |
right = stack.pop(); | |
left = stack.pop(); |
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.Comparator; | |
public class Quicksort { | |
public static void sort(Comparable<?>[] data, int left, int right) { | |
if (left < right) { | |
int pi = partition(data, left, right); | |
sort(data, left, pi-1); | |
sort(data, pi+1, right); | |
} | |
} |