Skip to content

Commit

Permalink
Небольшие улучшения
Browse files Browse the repository at this point in the history
  • Loading branch information
LazarenkoA committed Dec 3, 2018
1 parent 2038eae commit 7adb800
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
Binary file added Main.exe
Binary file not shown.
35 changes: 20 additions & 15 deletions Main.go
Expand Up @@ -47,30 +47,20 @@ type mapData map[string]*Data

const AddSizeChan = 10

var SortByCount, SortByValue, IO, v bool
var SortByCount, SortByValue, IO, v, cpuprofile, memprofile bool
var Top, Go int
var RootDir string
var RootDir, Event string

func main() {
defer new(ProfTime).Start().Stop()

flag.BoolVar(&SortByCount, "SortByCount", false, "Сортировка по количеству вызовов (bool)")
flag.BoolVar(&SortByValue, "SortByValue", false, "Сортировка по значению (bool)")
flag.BoolVar(&IO, "io", false, "Флаг указывающий, что данные будут поступать из StdIn (bool)")
//flag.BoolVar(&v, "v", false, "Флаг включающий вывод лога. Не используется при чтении данных из потока StdIn (bool)")
flag.IntVar(&Top, "Top", 100, "Ограничение на вывод по количеству записей")
flag.IntVar(&Go, "Go", 10, "Количество воркеров которые будут обрабатывать файл")
flag.StringVar(&RootDir, "RootDir", "", "Корневая директория")
parsFlag()

cpuprofile := flag.Bool("cpuprof", false, "Профилирование CPU (bool)")
memprofile := flag.Bool("memprof", false, "Профилирование памяти (bool)")
flag.Parse()

if *cpuprofile {
if cpuprofile {
StartCPUProf()
defer pprof.StopCPUProfile()
}
if *memprofile {
if memprofile {
StartMemProf()
defer pprof.StopCPUProfile()
}
Expand All @@ -85,6 +75,21 @@ func main() {

}

func parsFlag() {
flag.BoolVar(&SortByCount, "SortByCount", false, "Сортировка по количеству вызовов (bool)")
flag.BoolVar(&SortByValue, "SortByValue", false, "Сортировка по значению (bool)")
flag.BoolVar(&IO, "io", false, "Флаг указывающий, что данные будут поступать из StdIn (bool)")
//flag.BoolVar(&v, "v", false, "Флаг включающий вывод лога. Не используется при чтении данных из потока StdIn (bool)")
flag.IntVar(&Top, "Top", 100, "Ограничение на вывод по количеству записей")
flag.IntVar(&Go, "Go", 10, "Количество воркеров которые будут обрабатывать файл")
flag.StringVar(&RootDir, "RootDir", "", "Корневая директория")
flag.BoolVar(&cpuprofile, "cpuprof", false, "Профилирование CPU (bool)")
flag.BoolVar(&memprofile, "memprof", false, "Профилирование памяти (bool)")
//flag.StringVar(&Event, "Event", "", "Событие ТЖ для группировки")

flag.Parse()
}

func readStdIn() {
mergeChan := make(chan mapData, Go*AddSizeChan)
mergeGroup := &sync.WaitGroup{}
Expand Down
18 changes: 9 additions & 9 deletions Tools/Chain.go
Expand Up @@ -5,7 +5,6 @@ import (
"strconv"
"strings"
"sync"

)

type IChain interface {
Expand All @@ -27,7 +26,7 @@ var ChainPool = sync.Pool{
}

func BuildChain() *Chain {
/* Element0 := Chain{
Element0 := Chain{
regexp: regexp.MustCompile(`(?si)[\d]+:[\d]+\.[\d]+[-](?P<Value>[\d]+)[,]CALL(?:.*?)p:processName=(?P<DB>[^,]+)(?:.+?)Module=(?P<Module>[^,]+)(?:.+?)Method=(?P<Method>[^,]+)`),
AgregateFileld: []string{"event", "DB", "Module", "Method"},
OutPattern: "(%DB%) CALL, количество - %count%, duration - %Value%\n%Module%.%Method%",
Expand All @@ -38,29 +37,30 @@ func BuildChain() *Chain {
NextElement: &Element0,
AgregateFileld: []string{"event", "DB", "Context"},
OutPattern: "(%DB%) %event%, количество - %count%, duration - %Value%\n%Context%",
} */
}

Element1 := Chain{
Element2 := Chain{
//preCondition: func(In string) bool { return strings.Contains(In, ",CALL") },
regexp: regexp.MustCompile(`(?si)[,]CALL(?:.*?)p:processName=(?P<DB>[^,]+)(?:.+?)Module=(?P<Module>[^,]+)(?:.+?)Method=(?P<Method>[^,]+)(?:.+?)MemoryPeak=(?P<Value>[\d]+)`),
NextElement: &Element1,
AgregateFileld: []string{"event", "DB", "Module", "Method"},
OutPattern: "(%DB%) CALL, количество - %count%, MemoryPeak - %Value%\n%Module%.%Method%",
}

Element2 := Chain{
Element3 := Chain{
regexp: regexp.MustCompile(`(?si)[,]CALL(?:.*?)p:processName=(?P<DB>[^,]+)(?:.+?)Context=(?P<Context>[^,]+)(?:.+?)MemoryPeak=(?P<Value>[\d]+)`),
NextElement: &Element1,
NextElement: &Element2,
AgregateFileld: []string{"DB", "Context"},
OutPattern: "(%DB%) CALL, количество - %count%, MemoryPeak - %Value%\n%Context%",
}

Element3 := Chain{
Element4 := Chain{
regexp: regexp.MustCompile(`(?si)[,]EXCP,(?:.*?)process=(?P<Process>[^,]+)(?:.*?)Descr=(?P<Context>[^,]+)`),
NextElement: &Element2,
NextElement: &Element3,
AgregateFileld: []string{"Process", "Context"},
OutPattern: "(%Process%) EXCP, количество - %count%\n%Context%",
}
return &Element3
return &Element4
}

func (c *Chain) Execute(SourceStr string) (string, string, int64) {
Expand Down

0 comments on commit 7adb800

Please sign in to comment.