public class Client {
Number of cycles performed by test performance
private static final int loop_num = 100000;
public static void Main (string[] args) {
Int[] score = new INT[100];
Initializing arrays and lists
list<integer> list = new arraylist<integer> (100);
for (int i=0;i<score.length;i++) {
Score[i] = i;
List.add (i);
}
Test Array Performance
Long begin = System.currenttimemillis ();
for (int i=0;i<loop_num;i++) {
SUM (score);
}
Long end = System.currenttimemillis ();
SYSTEM.OUT.PRINTLN (array) Execution time: + (End-begin) + "MS");
Test List Execution Time
for (int i=0;i<loop_num;i++) {
sum (list);
}
SYSTEM.OUT.PRINTLN (list) Execution time: + (System.currenttimemillis ()-end) + "MS");
}
Sum of pairs of groups
public static int sum (int[] datas) {
int sum = 0;
for (int i=0;i<datas.length;i++) {
Sum +=datas[i];
}
return sum;
}
Sum the list
public static int sum (list<integer> datas) {
int sum = 0;
for (int i=0;i<datas.size (); i++) {
Sum +=datas.get (i);
}
return sum;
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.