Code Monkey home page Code Monkey logo

curieo_debasmit's Introduction

Error Log Monitor System

Overview

This repository contains the solution for the Curieo.org assignment, specifically an Error Log Monitor System implemented in Python 3.9.

Prerequisites

  • Python 3.9

Setup Instructions

  1. Clone the repository:

    git clone https://github.com/DEBASMITROY2002/Curieo_debasmit.git
  2. Navigate to the repository folder:

    cd Curieo_debasmit
  3. Create an 'input.txt' file in the repository folder to provide input data.

Sample input.txt Format

1715744138011;INTERNAL_SERVER_ERROR;23.72
1715744138012;INTERNAL_SERVER_ERROR;10.17
INTERNAL_SERVER_ERROR
1715744138012;BAD_REQUEST;15.22
1715744138013;INTERNAL_SERVER_ERROR;23.72
BEFORE 1715744138011
AFTER 1715744138010
BEFORE INTERNAL_SERVER_ERROR 1715744138011
AFTER INTERNAL_SERVER_ERROR 1715744138010

Note: Error types should not contain any non-alphanumeric characters except underscores. Ensure there are no extra whitespaces.

Execution

To run the program, execute the following command:

python3 run.py

Time complexity

If n is the total number of logs.

  1. Time complexity for inserting each log into our data structure is ๐‘‚ ( 1 ) (amortized).
  2. Time complexity for each query is ๐‘‚ ( log โก ๐‘› ).

Space complexity

The order is : O(n)

Example Image1

Data Structures Used

  1. Prefix array for storing minimum, maximum, and summation using python 1d list
  2. Monotonic stack for suffix min/max using python 1d list
  3. Map using python dictionary

Example Image2

Logic

  1. Each log type is mapped to its associated log entry object using string-to-object mapping. Therefore, accessing log entries under each log type is done in O(1)
  2. Each log entry object contains prefix-suffix utilities, total severities, and timestamps in increasing order of timestamps.
  3. Accessing timestamps using binary search requires O(log n) time.
  4. Each query over the prefix array requires O(1) time.
  5. Each query over the Monotonic stack requires O(log n) using binary search.
  6. The insertion of n elements into the monotonic stack takes O(n) time , resulting in O(1) time per element (amortized).
  7. The Suffix mean is calculated using: (Total Sum - Prefix Sum + Current Element) / (n-index)

Generate Test Case

cd test
python3 gen_testcase.py

Now the 'test/test_cases.txt' is generated.

The brute-force logic is in the 'test/brute_force.py'. Running this will generate 'test/output_test.txt'.

We can use 'pytest' to validate the results.

pip install pytest
python3 run.py test/test_cases.txt
cd test
python3 brute_force.py
pytest test.py

Example Image1

curieo_debasmit's People

Contributors

debasmitroy2002 avatar

Watchers

 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.