Kamper - a small KMM/KMP library that provides performance monitoring for your app.

Overview

🎯 Kamper

GitHub GitHub issues GitHub tag (latest by date) GitHub Repo stars

Kamper is a KMP/KMM library that implements a unified way to track application performances. The solution is based on plugin design patterns.

πŸ–ΌοΈ Screenshots

CPU FPS Memory Network
android android android android

πŸ’» Supported platforms

Platform Status
Android βœ…
JVM 🚧
iOS ❓
Windows ❓
MacOs ❓
Linux ❓

Android

Min required api for kamper is 16.

Module Api level
CPU Work as expected on all versions bellow 26 <. For +26 the system usage is not reported (Under investigation)
FPS +16
Memory +16
Network +23

⬇️ Install

Android

To Install the library in your project you need:

repositories {
    maven("https://maven.pkg.github.com/smellouk/kamper")
}

then

dependencies {
    implementation("com.smellouk.kamper:engine:$KAMPER_VERSION")
    // Implement the needed modules
    implementation("com.smellouk.kamper:cpu-module:$KAMPER_VERSION")
    implementation("com.smellouk.kamper:fps-module:$KAMPER_VERSION")
    implementation("com.smellouk.kamper:memory-module:$KAMPER_VERSION")
    implementation("com.smellouk.kamper:network-module:$KAMPER_VERSION")
}

πŸ—οΈ ️ Usage

Android

Lifecycle

By default the library is lifecycle aware, you can add it to your activity without the need of caring of kampers' lifecycle.

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        lifecycle.addObserver(Kamper) // Added to lifecycle manager
    }
}

if you wish to handle the library lifecycle then you need:

    fun start() {
    // Will start the kamper engine
    Kamper.start()
}

fun stop() {
    // Will stop kamper engine
    Kamper.stop()
}

fun clean() {
    // Will clean kamper engine from installed modules and clean all added listeners
    // (This is critical to not miss it due to the added listeners, otherwise if you forget it, it will introduce memory leaks)
    Kamper.clean()
}

For production

Kamper is production-ready. it also offers a way to install only the needed modules.

dependencies {
    // Don't forget to implement the needed module
    implementation("com.smellouk.kamper:cpu-module:$KAMPER_VERSION")
    implementation("com.smellouk.kamper:fps-module:$KAMPER_VERSION")
    implementation("com.smellouk.kamper:memory-module:$KAMPER_VERSION")
    implementation("com.smellouk.kamper:network-module:$KAMPER_VERSION")
}
fun initKamper() {
    Kamper.setup {
        logger = if (isDebug) Logger.DEFAULT else Logger.EMPTY
    }.apply {
        // CPU
        // Quick install default(isEnabled=true, intervalInMs=1000, logger=Logger.EMPTY)
        install(CpuModule)
        // Or
        install(
            CpuModule {
                isEnabled = cpuMonitoringIsEnabled
                intervalInMs = 1000
                logger = if (isDebug) Logger.DEFAULT else Logger.EMPTY
            }
        )
        addInfoListener<CpuInfo> { cpuInfo ->
            if (cpuInfo != CpuInfo.INVALID) {
                // Update UI or send it to your default tracking tool
            } else {
                // Do something else
            }
        }
        
        // FPS
        // Quick install default(isEnabled=true, logger=Logger.EMPTY)
        install(FpsModule)
        // Or
        install(
            FpsModule {
                isEnabled = isFpsModuleEnabled
                logger = if (isDebug) Logger.DEFAULT else Logger.EMPTY
            }
        )
        addInfoListener<FpsInfo> { fpsInfo ->
            if (fpsInfo != FpsInfo.INVALID) {
                // Update UI or send it to your default tracking tool
            } else {
                // Do something else
            }
        }
        
        // Memory
        install(
            MemoryModule(applicationContext) {
                isEnabled = isMemoryModuleEnabled
                intervalInMs = 1000
                logger = if (isDebug) Logger.DEFAULT else Logger.EMPTY
            }
        )
        addInfoListener<MemoryInfo> { memoryInfo ->
            if (memoryInfo != MemoryInfo.INVALID) {
                // Update UI or send it to your default tracking tool
            } else {
                // Do something else
            }
        }
        
        // Network
        // Quick install default(isEnabled=true, intervalInMs=1000,logger=Logger.EMPTY)
        install(NetworkModule)
        // Or
        install(
            NetworkModule {
                isEnabled = isNetworkModuleEnabled
                intervalInMs = 1000
                logger = if (isDebug) Logger.DEFAULT else Logger.EMPTY
            }
        )
        addInfoListener<NetworkInfo> { memoryInfo ->
            if (memoryInfo != NetworkInfo.INVALID) {
                // Update UI or send it to your default tracking tool
            } else {
                // Do something else
            }
        }
    }
}

For Debug/Qa

Kamper also offers UI debug tools that allow you to monitor app performance visually. This tool could be used for debugging purposes or for Qa testing.

Feature still under development[coming soon.]

✨ Samples/Demos

Our samples dir showcase how to use the library. (Currently, the samples are only for android)

Use cases:

  • High usage of CPU [CPU performance]
  • FPS usage of the main thread [FPS performance]
  • High usage of the memory [Memory performance]
  • High usage of the bandwidth [Network performance]

πŸ€” How-tos

  • How to test maven publishing locally?

To publish a version locally for testing purposes you just need to call

./gradlew publishAllPublicationsToLocalMavenRepository

The created artifacts can be found in the root build/maven directory.

  • How I can create a new performance module?

check our available modules[kamper/modules] and follow the same design or contact us for any support by creating a github issue.

🀝 Contribution

We're looking for contributors, help us to improve Kamper.

Please check our contribution guide.

πŸ™ Acknowledgments

Big thanks to Kyson/AndroidGodEye for inspiration.

βš– License

Copyright 2021 S. Mellouk

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • #28 πŸ› Fix performance module creation

    #28 πŸ› Fix performance module creation

    resolves #28

    πŸš€ Description

    Fixed module performance creation by creating instances when it's needed.

    πŸ“„ Motivation and Context

    #28

    βœ… Checklist

    • [x] My code follows our contribution guide.
    • [ ] I have added unit tests to cover the changes.
    • [x] I have used and tested this on my device(s).
    • [x] I have cleaned commit history.
    • [ ] I have updated README.md (if applicable)
    opened by smellouk 0
  • #23 🌟 Add kamper android samples

    #23 🌟 Add kamper android samples

    resolves #23

    πŸš€ Description

    Added android samples for CPU, FPS, Memory and network.

    πŸ“„ Motivation and Context

    #23

    πŸ§ͺ How Has This Been Tested?

    Run samples.android

    βœ… Checklist

    • [ x My code follows our contribution guide.
    • [ ] I have added unit tests to cover the changes.
    • [x] I have used and tested this on my device(s).
    • [x] I have cleaned commit history.
    • [ ] I have updated README.md (if applicable)

    πŸ“· Screenshots (if applicable)

    image image image image image

    opened by smellouk 0
  • Android Samples are working as expected.

    Android Samples are working as expected.

    For CPU, FPS and Network are not showing anything when you try to exit the screen and open it again.

    The issue is related to an expired module, which was not released when the camper called clean

    bug android 
    opened by smellouk 0
  • #26 πŸ› Fix network info for android devices < 23api

    #26 πŸ› Fix network info for android devices < 23api

    resolves #26

    πŸš€ Description

    Added a logic that catches when devices are not supported and send a NOT_SUPPORTED object to let the client know about the issue.

    πŸ“„ Motivation and Context

    #26

    πŸ§ͺ How Has This Been Tested?

    Run the fix on android device >= 23 and on android device < 23.

    βœ… Checklist

    • [x] My code follows our contribution guide.
    • [x] I have added unit tests to cover the changes.
    • [x] I have used and tested this on my device(s).
    • [x] I have cleaned commit history.
    • [ ] I have updated README.md (if applicable)
    opened by smellouk 0
  • Network module is not working as expected for android < 23

    Network module is not working as expected for android < 23

    TrafficStats.getTotalRxBytes, TrafficStats.getTotalTxBytes, TrafficStats.getUidRxBytes and TrafficStats.getUidTxBytes return -1 for android < 23, the implementation relies on NetworkStatsManager which available only for android >= 23.

    The fix should return correct Network Info or return NOT_SUPPORTED for devices which does not supports TrafficStats

    bug android 
    opened by smellouk 0
  • #24 πŸ› Fix wrong pss info on memory module

    #24 πŸ› Fix wrong pss info on memory module

    resolves #24

    πŸš€ Description

    Fixed wrong pss info data by adding the conversion to the correct unit. Also, remove the unused fields.

    πŸ“„ Motivation and Context

    #24

    πŸ§ͺ How Has This Been Tested?

    Run unit tests or samples apps.

    βœ… Checklist

    • [x] My code follows our contribution guide.
    • [x] I have added unit tests to cover the changes.
    • [x] I have used and tested this on my device(s).
    • [x] I have cleaned commit history.
    • [ ] I have updated README.md (if applicable)
    opened by smellouk 0
  • #20 Add gradle maven publish and github action to publish to gh packages

    #20 Add gradle maven publish and github action to publish to gh packages

    resolves #20

    πŸš€ Description

    Added gradle maven publisher to publish module:

    • Engine
    • CPU
    • FPS
    • Memory
    • Network

    Added github action to publish new maven packages whenever new tag is pushed.

    πŸ“„ Motivation and Context

    For fast releasing.

    πŸ§ͺ How Has This Been Tested?

    you can test the maven publishing part by running

    ./gradlew publishAllPublicationsToLocalMavenRepository
    

    βœ… Checklist

    • [x] My code follows our contribution guide.
    • [ ] I have added unit tests to cover the changes.
    • [x] I have used and tested this on my device(s).
    • [x] I have cleaned commit history.
    • [ ] I have updated README.md (if applicable)
    opened by smellouk 0
  • #18 πŸ§ͺ Add missing unit tests

    #18 πŸ§ͺ Add missing unit tests

    πŸš€ Description

    For each module, we added missing unit tests.

    πŸ“„ Motivation and Context

    More test coverage more quality.

    πŸ§ͺ How Has This Been Tested?

    run ./gradlew test

    βœ… Checklist

    • [x] My code follows our contribution guide.
    • [x] I have added unit tests to cover the changes.
    • [x] I have used and tested this on my device(s).
    • [x] I have cleaned commit history.
    • [ ] I have updated README.md (if applicable)
    opened by smellouk 0
  • Add missing unit tests

    Add missing unit tests

    The current solution does not have unit tests for common code and android code, your task is to cover the critical classes for common code and for android platform code.

    opened by smellouk 0
  • #9 🌟 Implement network performance module

    #9 🌟 Implement network performance module

    resolves #9

    πŸš€ Description

    Implemented network performance module, by using TrafficStats as source info.

    πŸ“„ Motivation and Context

    To monitor network performace.

    πŸ§ͺ How Has This Been Tested?

    • Run sampples.android on device +26 and device -26 You should see:
    2021-12-28 13:34:45.050 4469-4492/com.smellouk.kamper.samples I/Kamper: NetworkInfo(rxSystemTotalInMb=0.0, txSystemTotalInMb=0.0, rxAppInMb=0.0, txAppInMb=0.0)
    

    βœ… Checklist

    • [x] My code follows our contribution guide.
    • [ ] I have added unit tests to cover the changes.
    • [x] I have used and tested this on my device(s).
    • [x] I have cleaned commit history.
    • [ ] I have updated README.md (if applicable)
    opened by smellouk 0
  • #8 🌟 Implement memory performance module

    #8 🌟 Implement memory performance module

    resolves #8

    πŸš€ Description

    Implemented memory performance module, the module relies on context to extract memory info. The implementation extracts: Memory Info for the app, memory info for the device and PSS info. All implementation relies on ActivityManager.getProcessMemoryInfo.

    πŸ“„ Motivation and Context

    To monitory memory usage.

    πŸ§ͺ How Has This Been Tested?

    • Run sampples.android on device +26 and device -26 You should see:
    2021-12-28 12:57:02.647 4275-4294/com.smellouk.kamper.samples I/Kamper: MemoryInfo(appMemoryInfo=AppMemoryInfo(freeMemoryInMb=2.5756845, maxMemoryInMb=384.0, allocatedInMb=12.486648), pssInfo=PssInfo(totalPssInMb=0.01783657, dalvikPssInMb=0.00442791, nativePssInMb=0.0031776428, otherPssInMb=0.010231018), ramInfo=RamInfo(availableRamInMb=1158.6719, totalRamInMb=1499.0195, lowRamThresholdInMb=216.0, isLowMemory=false))
    

    βœ… Checklist

    • [x] My code follows our contribution guide.
    • [ ] I have added unit tests to cover the changes.
    • [x] I have used and tested this on my device(s).
    • [x] I have cleaned commit history.
    • [ ] I have updated README.md (if applicable)
    opened by smellouk 0
  • Create UI Tool for debug/qa purpose

    Create UI Tool for debug/qa purpose

    The UI representation will be something similar pluto/chucker where engineers can check the performance of the app easilly.

    Screens:

    • Logs
      • Will contains a screen that shows a list of logs of all installed performances, it also allows the user to download the logs as CSV files.
    • CPU
      • Will contain charts over time
    • FPS
      • Will contain charts over time
    • Memory
      • Will contain charts over time
    • Network
      • Will contain charts over time
    task android 
    opened by smellouk 0
  • Investigate Simpleperf as replacement for CPU profiling

    Investigate Simpleperf as replacement for CPU profiling

    Resources: https://android.googlesource.com/platform/system/extras/+/master/simpleperf/doc/README.md https://developer.android.com/ndk/guides/simpleperf https://cdmana.com/2020/11/20201113154332527b.html

    android timebox 
    opened by smellouk 0
Owner
S. Mellouk
S. Mellouk
Minecraft 1.18.2 Backport of Petal, a performance-oriented fork of Purpur intended to increase performance for entity-heavy servers by implementing multi-threaded and asynchronous improvements.

Sakura Performance Minecraft JAR Sakura is a performance-oriented fork of Purpur intended to increase performance for entity-heavy servers by implemen

etil.sol 14 Nov 23, 2022
KaMP Kit is to facilitate your evaluation of Kotlin Multiplatform (aka KMP)

KaMP Kit Welcome to the KaMP Kit! About Goal The goal of the KaMP Kit is to facilitate your evaluation of Kotlin Multiplatform (aka KMP). It is a coll

bas 0 Oct 25, 2021
KMP library for string unicode normalization

doistx-normalize Kotlin Multiplatform (KMP) library that adds support for normalization as described by Unicode Standard Annex #15 - Unicode Normaliza

Doist 31 Nov 22, 2022
Library to use Kotlin Coroutines from Swift code in KMP apps

KMP-NativeCoroutines A library to use Kotlin Coroutines from Swift code in KMP apps. Flows Kotlin Create an extension property to expose the Flow as a

Rick Clephas 508 Jan 3, 2023
Kotlin Multiplatform (KMP) library for reading resources in tests

kotlinx-resources Kotlin Multiplatform (KMP) plugin and library that add support for reading resources in tests. The plugin and a library work in tand

Gonçalo Silva 29 Dec 27, 2022
Kotlinx-murmurhash - Kotlin Multiplatform (KMP) library for hashing using MurmurHash

kotlinx-murmurhash Kotlin Multiplatform (KMP) library for MurmurHash, a non-cryp

Gonçalo Silva 23 Dec 27, 2022
Petrus Nguyα»…n ThΓ‘i Học 50 Jan 7, 2023
An unofficial Mangadex app using KMM

Mochi An unofficial Mangadex app using KMM. The app uses Mangadex new Public API, which may change at any time. ☒️ !!!Currently in Production. Not int

Michael24884 2 Jan 25, 2022
Example KMM app for showing about layered architecture

Layered Architecture in a Kotlin Multiplatform project This project was created by a series of posts you can find on my blog https://jflavio.com The d

Jose Flavio Quispe IrrazΓ‘bal 13 Oct 10, 2022
A simple KMM app

Getting Ready Install latest Android Studio version (I’m using RC Dolphin). Make sure your Kotlin Plugin has 1.7.x version. Make sure you have Ruby ge

Lena Stepanova 2 Sep 20, 2022
Template (pure) for KMM application with DI support

KMM di template Template (pure) for KMM application with DI support. Uses Multiplatform-DI for Dependency Injection Features Common architecture (VIP)

Anna Zharkova 8 Oct 18, 2022
An awesome list that curates the best KMM libraries, tools and more.

Awesome KMM Kotlin Multiplatform Mobile (KMM) is an SDK designed to simplify creating cross-platform mobile applications. With the help of KMM, you ca

Konstantin 994 Dec 28, 2022
Ricky and Morty episode guide using KMM and Apollo GraphQL Native

Ricky And Morty Episodes - Kmm Ricky and Morty episode guide using KMM and Apollo GraphQL Native This is a simple guide on how to create an KMM projec

Julio Ribeiro 2 Apr 15, 2022
use kmm to write a flutter plugin

use KMM to write a flutter plugin The reference plugin_codelab example plugin that accompanies the How to write a Flutter plugin codelab. I changed pl

libill 8 Nov 9, 2022
KMM RSS Reader: an open-source, mobile, cross-platform application built with Kotlin Multiplatform Mobile.

KMM RSS Reader This is an open-source, mobile, cross-platform application built with Kotlin Multiplatform Mobile. It's a simple RSS reader, and you ca

Kotlin 1.4k Jan 4, 2023
Demo for Jetbrains webinar on "How to share data layer in KMM"

RealmDemo Demo application demostrating how to share data layer in an KMM project using Realm Kotlin SDK and Atlas App Service. Webinar Link : https:/

MongoDB Developer Relations 9 Dec 15, 2022
A Kotlin library providing a simple, high-performance way to use off-heap native memory in JVM applications.

native_memory_allocator A library which uses sun.misc.Unsafe to allocate off-heap native memory. Motivation The goal of this project is to provide a s

Target 5 Dec 8, 2022
Android project setup files when developing apps from scratch. The codebase uses lates jetpack libraries and MVVM repository architecture for setting up high performance apps

Android architecture app Includes the following Android Respository architecture MVVM Jepack libraries Carousel view Kotlin Kotlin Flow and Livedata P

null 2 Mar 31, 2022
A high-performance fork of Paper/Airplane designed for large servers.

Pufferfish A highly optimized Paper/Airplane fork designed for large servers requiring both maximum performance, stability, and "enterprise" features.

Pufferfish Studios LLC 399 Jan 7, 2023