runtest.py :  » ERP » frePPLe » frepple-0.8.0 » test » scalability_3 » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » ERP » frePPLe 
frePPLe » frepple 0.8.0 » test » scalability_3 » runtest.py
#!/usr/bin/python
#
# Copyright (C) 2007 by Johan De Taeye
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
#  file     : $URL: https://frepple.svn.sourceforge.net/svnroot/frepple/tags/0.8.0/test/scalability_3/runtest.py $
#  revision : $LastChangedRevision: 1012 $  $LastChangedBy: jdetaeye $
#  date     : $LastChangedDate: 2009-08-06 08:14:40 +0200 (Thu, 06 Aug 2009) $

import os, sys, random

runtimes = {}

for counter in [500,1000,1500,2000]:
  print "\ncounter", counter
  out = open("input.xml","wt")

  # Print a header
  print >>out, ('<plan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n' +
    '<description>Single buffer plan with $counter demands</description>\n' +
    '<current>2009-01-01T00:00:00</current>\n' +
    '<items>\n' +
      '\t<item name="ITEM">' +
      '<operation name="Delivery ITEM" xsi:type="operation_fixed_time"/>' +
      '</item>\n' +
    '</items>\n' +
    '<operations>\n' +
      '\t<operation name="Make ITEM" xsi:type="operation_fixed_time"/>\n' +
    '</operations>\n' +
    '<buffers>\n' +
      '\t<buffer name="BUFFER"><onhand>10</onhand>' +
      '<producing name="Make ITEM"/>' +
      '</buffer>\n' +
    '</buffers>\n' +
    '<flows>\n' +
      '\t<flow xsi:type="flow_start"><operation name="Delivery ITEM"/>' +
      '<buffer name="BUFFER"/>' +
      '<quantity>-1</quantity></flow>\n' +
      '\t<flow xsi:type="flow_end"><operation name="Make ITEM"/>' +
      '<buffer name="BUFFER"/>' +
      '<quantity>1</quantity></flow>\n' +
    '</flows>\n' +
    '<demands>')

  # A loop to print all demand
  for cnt in range(counter):
    month = "%02d" % (int(random.uniform(0,12))+1)
    day = "%02d" % (int(random.uniform(0,28))+1)
    print >>out, ("<demand name=\"DEMAND %d\" quantity=\"10\" " +
      "due=\"2009-%s-%sT00:00:00\" " +
      "priority=\"1\">" +
      "<item name=\"ITEM\"/>" +
      "</demand>") % (cnt,month,day)

  # Finalize the input
  print >>out, ('</demands>\n' +
    '<?python\n' +
    'import frepple\n' +
    'frepple.solver_mrp(name="MRP",constraints=0).solve()\n' +
    'frepple.saveXMLfile("output.xml")\n' +
    '?>\n' +
    '</plan>')
  out.close()

  # Run the executable
  starttime = os.times()
  out = os.popen(os.environ['EXECUTABLE'] + "  ./input.xml")
  while True:
    i = out.readline()
    if not i: break
    print i.strip()
  if out.close() != None:
    print "Planner exited abnormally"
    sys.exit(1)

  # Measure the time
  endtime = os.times()
  runtimes[counter] = endtime[4]-starttime[4]
  print "time: %.3f" % runtimes[counter]

# Define failure criterium
if runtimes[2000] > runtimes[500]*4*1.2:
  print "\nTest failed. Run time is not linear with model size."
  sys.exit(1)

print "\nTest passed"
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.