Skip to content

Instantly share code, notes, and snippets.

View 0qdk4o's full-sized avatar
💭
勉強,study,学习

0qdk4o 0qdk4o

💭
勉強,study,学习
View GitHub Profile
@0qdk4o
0qdk4o / algo1.go
Created December 13, 2017 09:53
求给定字符串的字符组合
// BSD 3-Clause License
//
// Copyright (c) 2017, 0qdk4o
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
@0qdk4o
0qdk4o / interview.go
Created October 31, 2017 04:51
just a test
// 有四个线程1、2、3、4。线程1的功能就是输出1,线程2的功能就是输出2,以此类推.........
// 现在有四个文件ABCD。初始都为空。现要让四个文件呈如下格式:
// A:1 2 3 4 1 2....
// B:2 3 4 1 2 3....
// C:3 4 1 2 3 4....
// D:4 1 2 3 4 1....
// 没必要用chan chan的切换代价是很大的 我一般能不用就不用,观察规律好像这样也可以生成目标文件
// 并且是用四个coroutine 写文件可以先写缓冲区再一次写4K或16K 这样会更高效 但这并不是本问题重点
@0qdk4o
0qdk4o / gist:2d02b059ac26e66d952f90bd4cff96ee
Last active September 24, 2017 11:56
golang string concatenation performance
首先参考 http://herman.asia/efficient-string-concatenation-in-go
另外补充: 连接效率,内存使用率还与所连接字符串长度本身是有影响的
与本机核数多少依然有影响
以下测试均在go version go1.9
func BenchmarkBuffer(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()