zhoutianjie/timemonitor


timemonitor

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.zhoutianjie:timemonitor:1.1'
	}
	dependencies {
		implementation("com.github.zhoutianjie:timemonitor:1.1")
	}
	<dependency>
	    <groupId>com.github.zhoutianjie</groupId>
	    <artifactId>timemonitor</artifactId>
	    <version>1.1</version>
	</dependency>

                            
    libraryDependencies += "com.github.zhoutianjie" % "timemonitor" % "1.1"
        
        

                            
    :dependencies [[com.github.zhoutianjie/timemonitor "1.1"]]
        
        

Readme


timemonitor

timemonitor
自定义代码打点计时器,用来统计某个模块或者某个方法的运行时间

获取引用

在project的gradle文件下添加
  allprojects {
   repositories {
    ...
    maven { url 'https://jitpack.io' }
   }
  }

在module的gradle文件下添加
dependencies {
   implementation 'com.github.zhoutianjie:timemonitor:v1.1'
  }

使用方法

获取不同模块的TimeMonitor,Monitor是自定义,用来区分不同模块或方法
TimeMonitor monitor = TimeMonitorManager.Instance().getTimeMonitor(MonitorId.monitorId_1.ordinal());
在要打点的模块或者方法前添加
monitor.startMonitor();

在要打点的方法或者模块运行结束之后调用
monitor.recordingTimeTag("tag");
这里对应的"tag",对应某个模块的不同子模块。

最后通过
long time = monitor.getmTimeTags().get("tag");
获取某个tag子模块的执行时间
源码比较简单,可以自行查看。这里我也只是熟悉一下jitPack的使用