mnemonic-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject [05/14] incubator-mnemonic git commit: MNEMONIC-154: Add a data generator for sorting bench
Date Mon, 21 Nov 2016 17:32:31 GMT
MNEMONIC-154: Add a data generator for sorting bench


Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/f2490dff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/f2490dff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/f2490dff

Branch: refs/heads/master
Commit: f2490dff2236c12ff6aacfda8c3b73e2fb38b17c
Parents: 51107ce
Author: Wang, Gang(Gary) <gang1.wang@intel.com>
Authored: Tue Nov 8 10:59:34 2016 -0800
Committer: Wang, Gang(Gary) <gang1.wang@intel.com>
Committed: Thu Nov 17 12:49:51 2016 -0800

----------------------------------------------------------------------
 .../mnemonic-sort-bench/bin/gen_data.py         | 53 ++++++++++++++++++++
 1 file changed, 53 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/f2490dff/mnemonic-benches/mnemonic-sort-bench/bin/gen_data.py
----------------------------------------------------------------------
diff --git a/mnemonic-benches/mnemonic-sort-bench/bin/gen_data.py b/mnemonic-benches/mnemonic-sort-bench/bin/gen_data.py
new file mode 100755
index 0000000..8112412
--- /dev/null
+++ b/mnemonic-benches/mnemonic-sort-bench/bin/gen_data.py
@@ -0,0 +1,53 @@
+#! /usr/bin/env python
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import argparse
+import sys
+import random
+
+parser = argparse.ArgumentParser()
+parser.add_argument("count", type=long, help="specify how many random numbers will be generated")
+parser.add_argument("-s", "--seed", help="specify the random seed")
+args = parser.parse_args()
+
+if args.seed:
+  seed = args.seed
+else:
+  seed = random.randint(0, sys.maxint)
+random.seed(seed)
+
+fn = "sort_data_{0}_{1}.dat".format(args.count, seed)
+afile = open(fn, "w", 512*1024*1024 )
+
+print("The generated data will be written to the file {0} with the seed {1}".format(fn, seed))
+try:
+  for i in xrange(args.count):
+    line = str(random.randint(1, 999999999)) + "\n"
+    afile.write(line)
+    if 0 == i % 1000000:
+      sys.stdout.write('.')
+      sys.stdout.flush()
+except ValueError:
+    pass
+
+afile.close()
+
+print("")
+print("The generated data have been written to the file {0} with the seed {1}\n".format(fn,
seed))
+


Mime
View raw message