Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Reduce the processing time of a function

Suppose we have a Java function (i.e. a translation function that converts a Java data structure to a Protobuf message) that takes 1ms to be executed. I would like to know what are the potential solutions to make it faster?

DeviceId deviceId = DeviceId.deviceId(outboundPacketProto.getDeviceId());
TrafficTreatment.Builder trafficTreatmentBuilder = DefaultTrafficTreatment.builder();

List<InstructionProto> instructionProtoList = outboundPacketProto.getTreatment()
        .getAllInstructionsList();

for(InstructionProto instructionProto: instructionProtoList)
{
    switch (instructionProto.getType())
    {
        case OUTPUT:
            trafficTreatmentBuilder
                    .setOutput(PortNumber.portNumber(instructionProto.getPort().getPortNumber()));
    }

    OutboundPacket outboundPacket = new DefaultOutboundPacket(
        deviceId, trafficTreatmentBuilder.build(),
        ByteBuffer.wrap(outboundPacketProto.getData().toByteArray()));

    return outboundPacket;
}

Comments