forked from x/icebergs
opt bench
This commit is contained in:
parent
222f5d2bcb
commit
306e8d2f60
@ -250,7 +250,7 @@ func _list_search(m *ice.Message, prefix, key, field, value string) {
|
||||
})
|
||||
defer m.Cost("search")
|
||||
|
||||
task.Sync(list, func(task *task.Task, lock *task.Lock) error {
|
||||
task.Wait(list, func(task *task.Task, lock *task.Lock) error {
|
||||
kit.CSV(kit.Format(task.Arg), 100000, func(index int, line map[string]string, head []string) {
|
||||
if line[field] != value {
|
||||
return
|
||||
|
@ -25,11 +25,14 @@ func _port_get(m *ice.Message, begin string) string {
|
||||
current = kit.Int(m.Conf(PORT, "meta.begin"))
|
||||
}
|
||||
for i := current; i < end; i++ {
|
||||
if m.Cmd(cli.SYSTEM, "lsof", "-i", kit.Format(":%d", i)).Append(cli.CMD_CODE) != "0" {
|
||||
m.Conf(PORT, "meta.current", i)
|
||||
m.Log_SELECT(PORT, i)
|
||||
return kit.Format("%d", i)
|
||||
if c, e := net.Dial("tcp", kit.Format(":%d", i)); e == nil {
|
||||
m.Info("port exists %v", i)
|
||||
defer c.Close()
|
||||
continue
|
||||
}
|
||||
m.Conf(PORT, "meta.current", i)
|
||||
m.Log_SELECT(PORT, i)
|
||||
return kit.Format("%d", i)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
@ -5,9 +5,7 @@ import (
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
"github.com/shylinux/icebergs/base/web"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
log "github.com/shylinux/toolkits/logs"
|
||||
"github.com/shylinux/toolkits/util/bench"
|
||||
"github.com/shylinux/toolkits/util/bench/redis"
|
||||
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@ -15,7 +13,6 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
func _bench_list(m *ice.Message, zone string, id string, field ...interface{}) {
|
||||
@ -53,15 +50,6 @@ func _bench_show(m *ice.Message, nconn, nreq int64, list []*http.Request) {
|
||||
m.Echo(s.Show())
|
||||
m.Echo("body: %d\n", body)
|
||||
}
|
||||
func _bench_redis(m *ice.Message, nconn, nreq int64, hosts []string, cmds []string) {
|
||||
m.Log_CONF(NCONN, nconn, NREQS, nreq, "cmds", cmds, "hosts", hosts)
|
||||
|
||||
s, e := redis.Redis(nconn, nreq, hosts, cmds, nil)
|
||||
m.Assert(e)
|
||||
|
||||
m.Echo("cmds: %s QPS: %.2f n/s AVG: %s time: %s \n", cmds, s.QPS,
|
||||
log.FmtDuration(s.Cost/time.Duration(s.NReq)), log.FmtDuration(s.EndTime.Sub(s.BeginTime)))
|
||||
}
|
||||
func _bench_engine(m *ice.Message, kind, name, target string, arg ...string) {
|
||||
for i := 0; i < len(arg); i += 2 {
|
||||
m.Option(arg[i], arg[i+1])
|
||||
@ -70,19 +58,6 @@ func _bench_engine(m *ice.Message, kind, name, target string, arg ...string) {
|
||||
nreqs := kit.Int64(kit.Select("1000", m.Option(NREQS)))
|
||||
m.Echo("nconn: %d nreqs: %d\n", nconn, nreqs*nconn)
|
||||
|
||||
if strings.HasPrefix(target, "redis://") {
|
||||
hosts := []string{}
|
||||
for _, v := range strings.Split(target, ",") {
|
||||
hosts = append(hosts, strings.TrimPrefix(v, "redis://"))
|
||||
}
|
||||
|
||||
cmds := strings.Split(name, ",")
|
||||
for _, cmd := range cmds {
|
||||
_bench_redis(m, nconn, nreqs, hosts, []string{cmd})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
list := []*http.Request{}
|
||||
for _, v := range strings.Split(target, ",") {
|
||||
switch ls := kit.Split(v); ls[0] {
|
||||
|
@ -218,7 +218,6 @@ func _field_show(m *ice.Message, name, text string, arg ...string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
m.Debug("what %v", data)
|
||||
|
||||
// 渲染引擎
|
||||
m.Option("meta", data)
|
||||
|
@ -47,7 +47,7 @@ func _alpha_find2(m *ice.Message, method, word string) {
|
||||
}
|
||||
|
||||
var mu sync.Mutex
|
||||
task.Sync(args, func(task *task.Task, lock *task.Lock) error {
|
||||
task.Wait(args, func(task *task.Task, lock *task.Lock) error {
|
||||
info := task.Arg.(os.FileInfo)
|
||||
file := path.Join(p, info.Name())
|
||||
kit.CSV(file, 100000, func(index int, value map[string]string, head []string) {
|
||||
|
5
type.go
5
type.go
@ -165,9 +165,10 @@ func (c *Context) _split(name string) []interface{} {
|
||||
case ":":
|
||||
switch kit.Value(item, kit.MDB_INPUT, ls[i+1]); ls[i+1] {
|
||||
case "textarea":
|
||||
kit.Value(item, "style.width", "300")
|
||||
kit.Value(item, "style.height", "150")
|
||||
kit.Value(item, "style.width", "360")
|
||||
kit.Value(item, "style.height", "120")
|
||||
case "button":
|
||||
kit.Value(item, kit.MDB_VALUE, "")
|
||||
button = true
|
||||
}
|
||||
case "=":
|
||||
|
Loading…
x
Reference in New Issue
Block a user