Skip to content

Commit

Permalink
threads
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeySpiridonov committed Feb 21, 2014
1 parent f8c317e commit aef5691
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/org/prflr/sdk/PRFLR.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.util.Log;
import org.prflr.sdk.PRFLRSender;


public final class PRFLR{
Expand All @@ -27,9 +25,11 @@ public static void init(Context c){
Log.d("PRFLR", e.toString());
}
}

public static void setOveflowCounter(int value) {
PRFLRSender.overflowCount = value;
}

public static void begin(String timerName) {
try {
PRFLRSender.begin(timerName);
Expand Down
14 changes: 10 additions & 4 deletions src/org/prflr/sdk/PRFLRSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public static void end(String timerName) {
* That's one of downsides of this realisations. You can't remove timer from another thread,
* unless you changed it's name.
*/
public static void end(String timerName, String info) {
public static void end(final String timerName, final String info) {
if (!init) return;
String thread = Long.toString(Thread.currentThread().getId());
final String thread = Long.toString(Thread.currentThread().getId());

Long startTime = timers.get(thread + timerName);

Expand All @@ -113,8 +113,14 @@ public static void end(String timerName, String info) {

Long now = System.nanoTime();
Long precision = (long) Math.pow(10, 3);
Double diffTime = (double) Math.round((double) (now - startTime) / 1000000 * precision) / precision;
send(timerName, diffTime, thread, info);
final Double diffTime = (double) Math.round((double) (now - startTime) / 1000000 * precision) / precision;

// send to exclusive thread
new Thread(new Runnable() {
public void run() {
send(timerName, diffTime, thread, info);
}
}).start();
}

private static String cut(String s, Integer maxLength) {
Expand Down

0 comments on commit aef5691

Please sign in to comment.