Text this: Performance and energy optimization of ternary optical computers based on tandem queuing system