An OJ system is an online system to test programs in programming contests automatically. Performance enhancement of OJ systems in SMP environment is described in this paper. First, we introduce the affinity algorithm to improve the precision of the user programs' processing time. Second, by using queuing theory, a theoretical analysis and improvement of the system's performance indicators are given. By implementing these mechanisms, the average capacity of simultaneously judging tasks will increase while the judging results will become more precise, and the total number of computers in an OJ system will decrease, yielding lower hardware costs.