Coder Social home page Coder Social logo

analyzer's Introduction

analyzer

this is a simple log analyzer.

GoDoc license Build Status Coverage Status

Thanks for your time

As this is a tool for other developers, I print all the information about an API rather than just print 90%,95%,99%.

the basic solution about the problem is traverse all the logs, group the used time in a map, and then calculate the percentile.

for example:

logTimes = [1,3,4,4,5,6,11...1000]
I will store them in a map group by 5 ms. so the map is :
groupedUsedTime = {0:4,5:2,10:1....}
then when we generate the report, we need to sort the map by key and calculate the percentile.

N=len(logTImes)
M=len(groupedUsedTIme)
traverse all the logs takes O(N) time complexity. and sort the map and generate the report need O(M+M*log(M) +M) time complexity. and we only need a map to store all the data, so the space complexity is O(M). the worst case is each log time is different and group them by 1 ms, which N==M.

Usage

all the executable file are in bin, or you can build it by yourself with go build .

linux/
mac/
windows/
./analyzer --help

Usage of ./analyzer:
  -d string
    	logs dir (default ".")
  -f string
    	file name regexp (default ".*.log")
  -l string
    	one line log regexp (default ".* /api/playeritems.* ([0-9]+)$")
  -o string
    	output file path (default "./report.txt")
  -t int
    	time's position in one line log regexp (default 1)

Example

./bin/mac/analyzer -d logs

Running the tests

go test -coverprofile analyzer

analyzer's People

Contributors

kai1987 avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

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.