added Perf bin

This commit is contained in:
2023-06-04 21:47:26 +02:00
parent d0c01800a6
commit 13fe7fbab1
3 changed files with 42 additions and 1 deletions

38
src/bin/Perf.hx Normal file
View File

@@ -0,0 +1,38 @@
package bin;
import kernel.peripherals.Peripherals.Peripheral;
import lib.CLIAppBase;
class Perf extends CLIAppBase {
public function new() {
registerSyncSubcommand("inspect",(args)->{
if (args.length < 1) return false;
var result = Peripheral.instance.inspect(args[0]);
if (result == null){
handle.writeLine("No peripheral found on side "+args[0]);
return true;
}
handle.writeLine("Types:");
for (type in result.types){
handle.writeLine(" "+type);
}
handle.writeLine("Methods:");
for (method in result.methods){
handle.writeLine(" "+method);
}
return true;
},"<side>");
registerSyncSubcommand("list",(args)->{
for (addr in Peripheral.instance.getAllAddresses()){
handle.writeLine('$addr => ${Peripheral.instance.getTypes(addr).join(", ")}');
}
return true;
});
}
}