-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More work with new libtorrent statistical framework.
- Loading branch information
Showing
8 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.frostwire.jlibtorrent; | ||
|
||
import com.frostwire.jlibtorrent.swig.stats_metric; | ||
|
||
/** | ||
* Describes one statistics metric from the session. | ||
* | ||
* @author gubatron | ||
* @author aldenml | ||
*/ | ||
public final class StatsMetric { | ||
|
||
public static final int TYPE_COUNTER = stats_metric.type_counter; | ||
public static final int TYPE_GAUGE = stats_metric.type_gauge; | ||
|
||
private final stats_metric sm; | ||
|
||
public StatsMetric(stats_metric sm) { | ||
this.sm = sm; | ||
} | ||
|
||
public stats_metric getSwig() { | ||
return sm; | ||
} | ||
|
||
public String getName() { | ||
return sm.getName(); | ||
} | ||
|
||
public int getValueIndex() { | ||
return sm.getValue_index(); | ||
} | ||
|
||
public int getType() { | ||
return sm.getType(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/com/frostwire/jlibtorrent/alerts/SessionStatsAlert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.frostwire.jlibtorrent.alerts; | ||
|
||
import com.frostwire.jlibtorrent.Vectors; | ||
import com.frostwire.jlibtorrent.swig.session_stats_alert; | ||
|
||
/** | ||
* The session_stats_alert is posted when the user requests session statistics by | ||
* calling post_session_stats() on the session object. Its category is | ||
* ``status_notification``, but it is not subject to filtering, since it's only | ||
* manually posted anyway. | ||
* | ||
* @author gubatron | ||
* @author aldenml | ||
*/ | ||
public final class SessionStatsAlert extends AbstractAlert<session_stats_alert> { | ||
|
||
public SessionStatsAlert(session_stats_alert alert) { | ||
super(alert); | ||
} | ||
|
||
/** | ||
* the number of microseconds since the session was | ||
* started. It represent the time when the snapshot of values was taken. When | ||
* the network thread is under heavy load, the latency between calling | ||
* post_session_stats() and receiving this alert may be significant, and | ||
* the timestamp may help provide higher accuracy in measurements. | ||
* | ||
* @return | ||
*/ | ||
public long getStatsTimestamp() { | ||
return alert.getTimestamp().longValue(); | ||
} | ||
|
||
/** | ||
* An array are a mix of *counters* and *gauges*, which | ||
* meanings can be queries via the session_stats_metrics() function on the session. | ||
* The mapping from a specific metric to an index into this array is constant for a | ||
* specific version of libtorrent, but may differ for other versions. The intended | ||
* usage is to request the mapping, i.e. call session_stats_metrics(), once | ||
* on startup, and then use that mapping to interpret these values throughout | ||
* the process' runtime. | ||
* | ||
* @return | ||
*/ | ||
public long[] getValues() { | ||
return Vectors.uint64_vector2longs(alert.getValues()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters