GithubHelp home page GithubHelp logo

goc2p's Issues

关于原书第一版中channel和goroutine一章载荷发生器 并发量公式

并发量 = 单个载荷的响应超时时间 / 载荷的发送间隔时间
1e9 / lps 代表了发送的间隔,
对这一段有疑问?
a) lps是发送频率可以理解,1e9 / lps 代表了发送的间隔 为什么这个可以作为发送间隔?
b)并发量 的公式 也是不理解?

另外再后续实现代码里,
func (gen *myGenerator) genLoad(throttle <-chan time.Time) {
callCount := uint64(0)
Loop:
for ; ; callCount++ {
select {
case <-gen.stopSign:
gen.handleStopSign(callCount)
break Loop
default:
}
gen.asyncCall()
if gen.lps > 0 {
select {
case <-throttle:
case <-gen.stopSign:
gen.handleStopSign(callCount)
break Loop
}
}
}
}

这里再start里其实只是一个goroutine启动,然后无限循环,这样的测试,其实每个发送请求之间并不是一起过去的,是一次循环一次循环出去的。那这个并发其实并不准确。为何不使用
for i =0 ; i < current ; i ++ {
go func() {
for {
//todo
}
}()
}
这样在启动起来之后,基本可以说同1s,有那么多goroutine 进行请求。

而上述循环中,不停开启goroutine,如果接口响应很快的话,基本是不可能有一个同一时间的压力

这里,我的理解是否有偏差,还望解答,谢谢。

Incorrect definition of `IsSuperset` !

code in basic/set

// 判断集合 one 是否是集合 other 的超集
func IsSuperset(one Set, other Set) bool {
	if one == nil || other == nil {
		return false
	}
	oneLen := one.Len()
	otherLen := other.Len()
	if oneLen == 0 || oneLen == otherLen {
		return false
	}
	if oneLen > 0 && otherLen == 0 {
		return true
	}
	for _, v := range other.Elements() {
		if !one.Contains(v) {
			return false
		}
	}
	return true
}

Proper super set is not equivalent of super set.
In other words, if one == other, then one issuperset of other(just like Python set.issuperset method).

	if oneLen == 0 || oneLen == otherLen {
		return false
	}

ConcurrentMap 内容无法转换成 JSON 字符串

package map1

import (
    "testing"
    "reflect"
    "fmt"
    "encoding/json"
)

func Test2JSON(t *testing.T){
    cmap := NewConcurrentMap(reflect.TypeOf(string("")), reflect.TypeOf(string("")))
    cmap.Put("k1", "v1")
    fmt.Printf("%v\n", cmap)

    bytes, err := json.Marshal(cmap) // 无法将内部数据转成 JSON
    if err == nil {
        fmt.Println(string(bytes))
    }else {
        fmt.Printf("err = %v\n",err)
    }
}

C:/Go\bin\go.exe test -v basic/map1 -run ^Test2JSON$
ConcurrentMap<string,string>{k1:v1}
{}
ok basic/map1 0.234s

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.