Loading tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGen.kt +5 −4 Original line number Diff line number Diff line Loading @@ -334,13 +334,14 @@ class HostStubGen(val options: HostStubGenOptions) { entry: ZipEntry, out: ZipOutputStream, ) { BufferedInputStream(inZip.getInputStream(entry)).use { bis -> // TODO: It seems like copying entries this way is _very_ slow, // even with out.setLevel(0). Look for other ways to do it. inZip.getInputStream(entry).use { ins -> // Copy unknown entries as is to the impl out. (but not to the stub out.) val outEntry = ZipEntry(entry.name) out.putNextEntry(outEntry) while (bis.available() > 0) { out.write(bis.read()) } ins.transferTo(out) out.closeEntry() } } Loading tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGenLogger.kt +22 −7 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ class HostStubGenLogger { return level.ordinal <= maxLogLevel.ordinal } private fun println(level: LogLevel, message: String) { fun println(level: LogLevel, message: String) { printers.forEach { if (it.logLevel.ordinal >= level.ordinal) { it.println(level, indent, message) Loading @@ -129,7 +129,7 @@ class HostStubGenLogger { } } private fun println(level: LogLevel, format: String, vararg args: Any?) { fun println(level: LogLevel, format: String, vararg args: Any?) { if (isEnabled(level)) { println(level, String.format(format, *args)) } Loading Loading @@ -185,14 +185,29 @@ class HostStubGenLogger { println(LogLevel.Debug, format, *args) } inline fun <T> iTime(message: String, block: () -> T): T { inline fun <T> logTime(level: LogLevel, message: String, block: () -> T): T { val start = System.currentTimeMillis() val ret = block() try { return block() } finally { val end = System.currentTimeMillis() if (isEnabled(level)) { println(level, String.format("%s: took %.1f second(s).", message, (end - start) / 1000.0)) } } } inline fun <T> iTime(message: String, block: () -> T): T { return logTime(LogLevel.Info, message, block) } log.i("%s: took %.1f second(s).", message, (end - start) / 1000.0) inline fun <T> vTime(message: String, block: () -> T): T { return logTime(LogLevel.Verbose, message, block) } return ret inline fun <T> dTime(message: String, block: () -> T): T { return logTime(LogLevel.Debug, message, block) } inline fun forVerbose(block: () -> Unit) { Loading Loading
tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGen.kt +5 −4 Original line number Diff line number Diff line Loading @@ -334,13 +334,14 @@ class HostStubGen(val options: HostStubGenOptions) { entry: ZipEntry, out: ZipOutputStream, ) { BufferedInputStream(inZip.getInputStream(entry)).use { bis -> // TODO: It seems like copying entries this way is _very_ slow, // even with out.setLevel(0). Look for other ways to do it. inZip.getInputStream(entry).use { ins -> // Copy unknown entries as is to the impl out. (but not to the stub out.) val outEntry = ZipEntry(entry.name) out.putNextEntry(outEntry) while (bis.available() > 0) { out.write(bis.read()) } ins.transferTo(out) out.closeEntry() } } Loading
tools/hoststubgen/hoststubgen/src/com/android/hoststubgen/HostStubGenLogger.kt +22 −7 Original line number Diff line number Diff line Loading @@ -121,7 +121,7 @@ class HostStubGenLogger { return level.ordinal <= maxLogLevel.ordinal } private fun println(level: LogLevel, message: String) { fun println(level: LogLevel, message: String) { printers.forEach { if (it.logLevel.ordinal >= level.ordinal) { it.println(level, indent, message) Loading @@ -129,7 +129,7 @@ class HostStubGenLogger { } } private fun println(level: LogLevel, format: String, vararg args: Any?) { fun println(level: LogLevel, format: String, vararg args: Any?) { if (isEnabled(level)) { println(level, String.format(format, *args)) } Loading Loading @@ -185,14 +185,29 @@ class HostStubGenLogger { println(LogLevel.Debug, format, *args) } inline fun <T> iTime(message: String, block: () -> T): T { inline fun <T> logTime(level: LogLevel, message: String, block: () -> T): T { val start = System.currentTimeMillis() val ret = block() try { return block() } finally { val end = System.currentTimeMillis() if (isEnabled(level)) { println(level, String.format("%s: took %.1f second(s).", message, (end - start) / 1000.0)) } } } inline fun <T> iTime(message: String, block: () -> T): T { return logTime(LogLevel.Info, message, block) } log.i("%s: took %.1f second(s).", message, (end - start) / 1000.0) inline fun <T> vTime(message: String, block: () -> T): T { return logTime(LogLevel.Verbose, message, block) } return ret inline fun <T> dTime(message: String, block: () -> T): T { return logTime(LogLevel.Debug, message, block) } inline fun forVerbose(block: () -> Unit) { Loading