[llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Oct 6 20:03:01 PDT 2003


Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++:

lists.cpp added (r1.1)

---
Log message:

new testcase


---
Diffs of the changes:  (+50 -2)

Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists.cpp
diff -c /dev/null llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists.cpp:1.1
*** /dev/null	Mon Oct  6 20:02:45 2003
--- llvm/test/Programs/SingleSource/Benchmarks/Shootout-C++/lists.cpp	Mon Oct  6 20:02:35 2003
***************
*** 0 ****
--- 1,50 ----
+ // -*- mode: c++ -*-
+ // $Id: lists.cpp,v 1.1 2003/10/07 01:02:35 lattner Exp $
+ // http://www.bagley.org/~doug/shootout/
+ // from Bill Lear
+ 
+ #include <iostream>
+ #include <list>
+ #include <numeric>
+ 
+ using namespace std;
+ 
+ const size_t SIZE = 10000;
+ 
+ size_t test_lists() {
+     std::list<size_t> li1(SIZE);
+ 
+     std::iota(li1.begin(), li1.end(), 1);
+ 
+     std::list<size_t> li2(li1);
+ 
+     std::list<size_t> li3;
+ 
+     size_t N = li2.size();
+     while (N--) {
+         li3.push_back(li2.front());
+         li2.pop_front();
+     }
+ 
+     N = li3.size();
+     while (N--) {
+         li2.push_back(li3.back());
+         li3.pop_back();
+     }
+ 
+     li1.reverse();
+ 
+     return (li1.front() == SIZE) && (li1 == li2) ? li1.size() : 0;
+ }
+ 
+ int main(int argc, char* argv[]) {
+     size_t ITER = (argc == 2 ? (atoi(argv[1]) < 1 ? 1 : atoi(argv[1])): 1);
+ 
+     size_t result = 0;
+     while (ITER > 0) {
+         result = test_lists();
+         --ITER;
+     }
+ 
+     std::cout << result << std::endl;
+ }





More information about the llvm-commits mailing list