---
title: "性能调优篇 1.0"
author: "Janle"
date: "2017-08-17T09:10:57Z"
tags: []
categories: ["编程语言"]
slug: "1-0"
draft: false
lastmod: "2017-08-17T09:21:38Z"
id: 2390071
url: "https://janle.iteye.com/blog/2390071"
---

**刻意追求，性能不佳**
同事写了一段牛逼的代码我以为这个是为了提升就像日志输出时候性能问题。但是在自己测试之后获得臆想不到的效果。

```java
import java.text.MessageFormat;
public class TestMessageFormmat {
    public static void main(String[] args) {
        String c;
        Long startFormat=System.currentTimeMillis();
        for (int i=0;i<100000;i++)
        c=MessageFormat.format("{0}{1}","a","b");
        Long endFormat=System.currentTimeMillis();

        Long start=System.currentTimeMillis();
        for (int i=0;i<100000;i++)
        c="a"+"b";
        Long end=System.currentTimeMillis();

        System.out.println("format time:"+(endFormat-startFormat)+"  time:"+(end-start));
    }
}
```

测试后的结果，我以为我第二个时间是没有记录么，后来debug处理了一下。并不是。

```java

format time:231  time:0

```