kopia lustrzana https://github.com/ge0rg/aprsdroid
remove database benchmarks
rodzic
d3a827ceeb
commit
267e5967fb
|
@ -55,7 +55,7 @@ class MessageListAdapter(context : Context, prefs : PrefsWrapper,
|
|||
|
||||
def load_cursor(i : Intent) = {
|
||||
val c = storage.getMessages(targetcall)
|
||||
Benchmark("getCount") { c.getCount() }
|
||||
c.getCount()
|
||||
c
|
||||
}
|
||||
|
||||
|
|
|
@ -39,10 +39,10 @@ class PositionListAdapter(context : Context, prefs : PrefsWrapper,
|
|||
|
||||
context.registerReceiver(locReceiver, new IntentFilter(AprsService.UPDATE))
|
||||
|
||||
private val DARK = Array(0xff, 0x60, 0x60, 0x40)
|
||||
private val BRIGHT = Array(0xff, 0xff, 0xff, 0xc0)
|
||||
private val MAX = 30*60*1000
|
||||
def getAgeColor(ts : Long) : Int = {
|
||||
val DARK = Array(0xff, 0x60, 0x60, 0x40)
|
||||
val BRIGHT = Array(0xff, 0xff, 0xff, 0xc0)
|
||||
val MAX = 30*60*1000
|
||||
val delta = (System.currentTimeMillis - ts).toInt
|
||||
val factor = if (delta < MAX) delta else MAX
|
||||
val mix = DARK zip BRIGHT map (t => { t._2 - (t._2 - t._1)*factor/MAX } )
|
||||
|
@ -98,7 +98,6 @@ class PositionListAdapter(context : Context, prefs : PrefsWrapper,
|
|||
|
||||
def load_cursor(i : Intent) = {
|
||||
import PositionListAdapter._
|
||||
Benchmark("get my position") {
|
||||
val cursor = storage.getStaPosition(mycall)
|
||||
if (cursor.getCount() > 0) {
|
||||
cursor.moveToFirst()
|
||||
|
@ -106,14 +105,13 @@ class PositionListAdapter(context : Context, prefs : PrefsWrapper,
|
|||
my_lon = cursor.getInt(StorageDatabase.Position.COLUMN_LON)
|
||||
}
|
||||
cursor.close()
|
||||
}
|
||||
val c = mode match {
|
||||
case SINGLE => storage.getStaPosition(targetcall)
|
||||
case NEIGHBORS => storage.getNeighbors(mycall, my_lat, my_lon,
|
||||
System.currentTimeMillis - prefs.getShowAge(), "50")
|
||||
case SSIDS => storage.getAllSsids(targetcall)
|
||||
}
|
||||
Benchmark("getCount") { c.getCount() }
|
||||
c.getCount()
|
||||
c
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ class StorageDatabase(context : Context) extends
|
|||
addMessage(cv)
|
||||
}
|
||||
|
||||
def getPositions(sel : String, selArgs : Array[String], limit : String) : Cursor = Benchmark("getPositions") {
|
||||
def getPositions(sel : String, selArgs : Array[String], limit : String) : Cursor = {
|
||||
getReadableDatabase().query(Position.TABLE, Position.COLUMNS_MAP,
|
||||
sel, selArgs,
|
||||
null, null, "CALL, _ID", limit)
|
||||
|
@ -218,23 +218,23 @@ class StorageDatabase(context : Context) extends
|
|||
Array(lat1, lat2, lon1, lon2).map(_.toString), limit)
|
||||
}
|
||||
|
||||
def getStaPosition(call : String) : Cursor = Benchmark("getStaPosition") {
|
||||
def getStaPosition(call : String) : Cursor = {
|
||||
getReadableDatabase().query(Position.TABLE, Position.COLUMNS,
|
||||
"call LIKE ?", Array(call),
|
||||
null, null, "_ID DESC", "1")
|
||||
}
|
||||
def getStaPositions(call : String, limit : String) : Cursor = Benchmark("getStaPositions") {
|
||||
def getStaPositions(call : String, limit : String) : Cursor = {
|
||||
getReadableDatabase().query(Position.TABLE, Position.COLUMNS,
|
||||
"call LIKE ? AND TS > ?", Array(call, limit),
|
||||
null, null, "_ID DESC", null)
|
||||
}
|
||||
def getAllSsids(call : String) : Cursor = Benchmark("getAllSsids") {
|
||||
def getAllSsids(call : String) : Cursor = {
|
||||
val querycall = call.split("[- _]+")(0) + "%"
|
||||
getReadableDatabase().query(Position.TABLE, Position.COLUMNS,
|
||||
"call LIKE ? or origin LIKE ?", Array(querycall, querycall),
|
||||
"call", null, null, null)
|
||||
}
|
||||
def getNeighbors(mycall : String, lat : Int, lon : Int, ts : Long, limit : String) : Cursor = Benchmark("getNeighbors") {
|
||||
def getNeighbors(mycall : String, lat : Int, lon : Int, ts : Long, limit : String) : Cursor = {
|
||||
// calculate latitude correction
|
||||
val corr = (cos(Pi*lat/180000000.)*cos(Pi*lat/180000000.)*100).toInt
|
||||
Log.d(TAG, "getNeighbors: correcting by %d".format(corr))
|
||||
|
@ -245,7 +245,7 @@ class StorageDatabase(context : Context) extends
|
|||
"call", null, "dist", limit)
|
||||
}
|
||||
|
||||
def getNeighborsLike(call : String, lat : Int, lon : Int, ts : Long, limit : String) : Cursor = Benchmark("getNeighborsLike") {
|
||||
def getNeighborsLike(call : String, lat : Int, lon : Int, ts : Long, limit : String) : Cursor = {
|
||||
// calculate latitude correction
|
||||
val corr = (cos(Pi*lat/180000000.)*cos(Pi*lat/180000000.)*100).toInt
|
||||
Log.d(TAG, "getNeighborsLike: correcting by %d".format(corr))
|
||||
|
|
Ładowanie…
Reference in New Issue