循环10万次输出打印hello world
语言 | 占用内存 | 包大小 | 耗时 |
---|---|---|---|
go | 5324k | 可执行文件:2172k | 平均8502毫秒 |
java | 175326k | 字节码文件:2k | 平均8537毫秒 |
dotnetcore | 3612k | 打包发布:65.4m | 平均8371毫秒 |
package main import ( "fmt" "os" "os/signal" "syscall" "time" ) func main() { t1 := time.Now() // get current time //logic handlers for i := 0; i < 100000; i++ { fmt.Println("hello world") } elapsed := time.Since(t1) fmt.Println("App elapsed: ", elapsed) sig := make(chan os.Signal, 2) signal.Notify(sig, syscall.SIGTERM, syscall.SIGINT) <-sig }
发布后的目录
import java.io.IOException; public class HelloWorld { public static void main(final String[] args) throws IOException { final long time1 = System.currentTimeMillis(); int i = 0; for (; i < 100000; i++) { System.out.println("hello world"); } final long time2 = System.currentTimeMillis(); System.out.println("当前程序耗时:" + (time2 - time1) + "ms"); System.in.read(); } }
编译后的目录
using System; using System.Diagnostics; using System.Threading.Tasks; using System.Threading; namespace netcore_prj { class Program { static async Task Main(string[] args) { var watch = new Stopwatch(); watch.Start(); for (var i = 0; i < 100000; i++) Console.WriteLine("hello world"); watch.Stop(); Console.WriteLine($"循环100000次Say Hello World,用时:{watch.ElapsedMilliseconds}ms"); Console.ReadLine(); } } }
发布后的目录
语言 | 虚拟内存 | 物理内存 | 包大小 | 耗时 |
---|---|---|---|---|
go | 100M | 976 | 2104k | 平均170ms |
java | 4647M | 33660 | 4k | 平均335ms |
dotnetcore | 2712M | 18988 | 110m | 平均144ms |
打包到以下的测试目录:
go: 直接运行 nohup ./go_main &
java: 运行编译后的字节码文件 nohup java HelloWorld &
dotnetcore: 进入netcore目录运行 nohup ./netcore_prj &
PID:进行的标识号
原文:https://www.cnblogs.com/ajdwfnhaps/p/12031226.html