GithubHelp home page GithubHelp logo

test-mass-forker-org-1 / omagnifier Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/omagnifier

0.0 0.0 0.0 166 KB

A performance monitor SDK for Android application

License: MIT License

Kotlin 100.00%

omagnifier's Introduction

OMagnifier

OMagnifier is an Android APM SDK that can be used to monitor the app performance.

Features Support

  • Frame rate monitor: floating window for showing fps
  • Memory usage metrics monitor: monitor and collect the memeory usage metrics
  • Memory usage viewer
  • Battery usage monitor

APIs

Frame rate monitor

  1. Start frame rate monitor
Magnifier.startMonitorFPS(
    FPSMonitorConfig.Builder(this.application)
        .lowPercentage(40 / 60f)  // show red tips, (2.0f / 3.0f) by default
        .mediumPercentage(50 / 60f) // show yellow tips, (5.0f / 6.0f) by default
        .refreshRate(60f) // defaultDisplay.refreshRate by default
        .build()
)
  1. Stop frame rate monitor
Magnifier.stopMonitorFPS()

Memory usage monitor

The mectrics we support now:

  • HeapMemoryInfo: heap memory and vss/pss memory
  • FileDescriptorInfo: file readlink and max open file count
  • ThreadInfo: thread count and thread stack trace
  1. Start Memory usage metrics monitor
MemoryMonitorConfig.Builder()
    .enableExceedLimitSample(0.8f, // the benchmark for Exceed_Limit type sampler, if we reach out 80% the max, collect the metrics, 0.8f by default
        10000 // the threshold for Exceed_Limit type sampler, 10s by default
    )
    .enableTimingSample(60 * 1000) // threshold for the timing checker, 1 min by default
    .onSampleListener(object : MemoryMonitor.OnSampleListener {
        override fun onSampleHeap(
            heapMemoryInfo: HeapMemoryInfo,
            sampleType: MemoryMonitor.SampleType
        ) {
            Log.d(TAG, "heapMemoryInfo:$heapMemoryInfo,sampleType:$sampleType")
        }

        override fun onSampleFile(
            fileDescriptorInfo: FileDescriptorInfo,
            sampleType: MemoryMonitor.SampleType
        ) {
            Log.d(TAG, "fileDescriptorInfo:${fileDescriptorInfo.fdMaxCount},sampleType:$sampleType")
        }

        override fun onSampleThread(
            threadInfo: ThreadInfo,
            sampleType: MemoryMonitor.SampleType
        ) {
            Log.d(TAG, "threadInfo:${threadInfo.threadsCount},sampleType:$sampleType")
        }
    }).build()
  1. Collect the memory usage metrics immdiately
Magnifier.dumpMemoryImmediately(object : MemoryMonitor.OnSampleListener {
    override fun onSampleHeap(
        heapMemoryInfo: HeapMemoryInfo,
        sampleType: MemoryMonitor.SampleType
    ) {
        Log.d(TAG, "heapMemoryInfo:$heapMemoryInfo,sampleType:$sampleType")
    }

    override fun onSampleFile(
        fileDescriptorInfo: FileDescriptorInfo,
        sampleType: MemoryMonitor.SampleType
    ) {
        Log.d(TAG, "fileDescriptorInfo:${fileDescriptorInfo.fdMaxCount},sampleType:$sampleType")
    }

    override fun onSampleThread(
        threadInfo: ThreadInfo,
        sampleType: MemoryMonitor.SampleType
    ) {
        Log.d(TAG, "threadInfo:${threadInfo.threadsCount},sampleType:$sampleType")
    }
})
  1. Stop frame rate monitor
Magnifier.stopMonitorMemory()

Demo

The demo is under Module app.

  1. Install the app
  2. Run the app
  3. Click the button for testing

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

License

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT license.

omagnifier's People

Contributors

ngwaikong avatar microsoftopensource avatar microsoft-github-operations[bot] 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.