JESS: Which is faster?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

JESS: Which is faster?

Donald Winston
Is there enough of a difference in performance between the following to worry about?

; from Jess
(assert (param-name1 ?param-value1))
(assert (param-name2 ?param-value2))
(assert (param-name3 ?param-value3a ?param-value3b ?param-value3c))
...,etc


                       v.s.

/* Assert ordered facts from the request parameter map. 
* No deftemplate is necessary (I have an unorderd fact version of this too) */
private void assertRequestParameters(HttpServletRequest request) throws JessException {
Map map = request.getParameterMap();
Iterator keys = map.keySet().iterator();
while (keys.hasNext() == true) {
String key = (String)keys.next();
Fact fact = new Fact(key, peerEngine);
String[] paramValues = (String[])map.get(key);
ValueVector values = new ValueVector();
for(String value : paramValues)
values.add(new Value(value, RU.STRING));
fact.setSlotValue("_data", new Value(values, RU.LIST));
peerEngine.assertFact(fact);
}
}

        
Reply | Threaded
Open this post in threaded view
|

Re: JESS: Which is faster?

Friedman-Hill, Ernest
No, just the small overhead of parsing.

 
From: Donald Winston [mailto:[hidden email]]
Sent: Tuesday, August 17, 2010 07:08 AM
To: jess-users
Subject: JESS: Which is faster?
 
Is there enough of a difference in performance between the following to worry about?

; from Jess
(assert (param-name1 ?param-value1))
(assert (param-name2 ?param-value2))
(assert (param-name3 ?param-value3a ?param-value3b ?param-value3c))
...,etc


                       v.s.

/* Assert ordered facts from the request parameter map. 
* No deftemplate is necessary (I have an unorderd fact version of this too) */
private void assertRequestParameters(HttpServletRequest request) throws JessException {
Map map = request.getParameterMap();
Iterator keys = map.keySet().iterator();
while (keys.hasNext() == true) {
String key = (String)keys.next();
Fact fact = new Fact(key, peerEngine);
String[] paramValues = (String[])map.get(key);
ValueVector values = new ValueVector();
for(String value : paramValues)
values.add(new Value(value, RU.STRING));
fact.setSlotValue("_data", new Value(values, RU.LIST));
peerEngine.assertFact(fact);
}
}