Skip to content

Instantly share code, notes, and snippets.

View draveness's full-sized avatar
🌟
𝚊𝚋𝚜𝚝𝚛𝚊𝚌𝚝𝚒𝚘𝚗 & 𝚌𝚘𝚖𝚙𝚕𝚎𝚡𝚒𝚝𝚢

Draven draveness

🌟
𝚊𝚋𝚜𝚝𝚛𝚊𝚌𝚝𝚒𝚘𝚗 & 𝚌𝚘𝚖𝚙𝚕𝚎𝚡𝚒𝚝𝚢
View GitHub Profile
package main
import (
"fmt"
"math/rand"
"sort"
"sync"
"time"
"github.com/RussellLuo/timingwheel"
@draveness
draveness / benchmark_mutex_and_channel_test.go
Created July 11, 2019 01:13
Benchmark Mutex vs Channel
package main
import (
"errors"
"sync"
"testing"
)
func BenchmarkChannel(b *testing.B) {
ch := make(chan error, 1)
@draveness
draveness / benchmark_timers.go
Created July 11, 2019 15:07
Benchmark Golang Timers
package main
import (
"fmt"
"sort"
"sync"
"testing"
"time"
)
@draveness
draveness / golang-syscall.csv
Created September 6, 2019 07:39
golang syscall type
Syscall Type
SYS_TIME RawSyscall
SYS_GETTIMEOFDAY RawSyscall
SYS_SETRLIMIT RawSyscall
SYS_GETRLIMIT RawSyscall
SYS_EPOLL_WAIT Syscall
SYS_MMAP2 Syscall
SYS__NEWSELECT Syscall
SYS_SETGROUPS32 RawSyscall
SYS_GETGROUPS32 RawSyscall
#include <math.h>
#include <stdio.h>
double attackerSuccessProbability(double q, int z) {
double p = 1.0 - q;
double lambda = z * (q / p);
double sum = 1.0;
int i, k;
for (k = 0; k <= z; k++) {
double poisson = exp(-lambda);
@draveness
draveness / float64_precision.go
Created April 21, 2020 13:19
Deposit and Withdraw with float64
package main
import (
"fmt"
)
var balance float64 = 0
func main() {
deposit(.1)
@draveness
draveness / benchmark_foreign_key.go
Last active October 14, 2020 07:42
Benchmark Foreign Key
package main
import (
"testing"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
)
type Post struct {