Permalink
Browse files

Merge branch 'release/0.2.8'

  • Loading branch information...
2 parents b52cc79 + dd68200 commit 14b109bdb8e52f03fe6d195ac1df8bf68861178f @aseemk aseemk committed Apr 25, 2012
Showing with 66 additions and 25 deletions.
  1. +5 −0 CHANGELOG.md
  2. +11 −7 lib/Path.coffee
  3. +18 −13 lib/PropertyContainer.coffee
  4. +12 −4 lib/Relationship.coffee
  5. +2 −1 package.json
  6. +18 −0 test/profile.coffee
View
@@ -1,3 +1,8 @@
+## Version 0.2.8 — April 25, 2012
+
+ - Optimized the construction of new object instances in our code. This shows
+ >50x improvement when creating or fetching many nodes or relationships.
+
## Version 0.2.7 — April 22, 2012
- Reversed the order of `GraphDatabase::query()` from `(callback, query)` to
View
@@ -8,11 +8,15 @@ module.exports = class Path
@_relationships = relationships
@_end = end
- @getter 'start', -> @_start || null
- @getter 'end', -> @_end || null
- @getter 'length', -> @_length || 0
- @getter 'nodes', -> @_nodes || []
- @getter 'relationships', -> @_relationships || []
+ # Language helpers:
+ get = (props) =>
+ @::__defineGetter__ name, getter for name, getter of props
+ set = (props) =>
+ @::__defineSetter__ name, setter for name, setter of props
- getter: @__defineGetter__
- setter: @__defineSetter__
+ # Properties:
+ get start: -> @_start || null
+ get end: -> @_end || null
+ get length: -> @_length || 0
+ get nodes: -> @_nodes || []
+ get relationships: -> @_relationships || []
@@ -13,21 +13,26 @@ module.exports = class PropertyContainer
@_data = data or {}
@_data.self = data?.self or null
- @getter 'self', -> @_data.self or null
- @getter 'exists', -> @self?
- @getter 'id', ->
- if not @exists
- null
- else
- match = /(?:node|relationship)\/(\d+)$/.exec @self
- parseInt match[1]
-
- @getter 'data', -> @_data.data or null
- @setter 'data', (value) -> @_data.data = value
+ # Language helpers:
+ get = (props) =>
+ @::__defineGetter__ name, getter for name, getter of props
+ set = (props) =>
+ @::__defineSetter__ name, setter for name, setter of props
+
+ # Properties:
+ get self: -> @_data.self or null
+ get exists: -> @self?
+ get id: ->
+ if not @exists
+ null
+ else
+ match = /(?:node|relationship)\/(\d+)$/.exec @self
+ parseInt match[1]
- getter: @::__defineGetter__
- setter: @::__defineSetter__
+ get data: -> @_data.data or null
+ set data: (value) -> @_data.data = value
+ # Methods:
equals: (other) ->
@self is other?.self
View
@@ -19,10 +19,18 @@ module.exports = class Relationship extends PropertyContainer
@_start = start or new Node db, {self: data.start}
@_end = end or new Node db, {self: data.end}
- @getter 'start', -> @_start or null
- @getter 'end', -> @_end or null
- @getter 'type', -> data.type
-
+ # Language helpers:
+ get = (props) =>
+ @::__defineGetter__ name, getter for name, getter of props
+ set = (props) =>
+ @::__defineSetter__ name, setter for name, setter of props
+
+ # Properties:
+ get start: -> @_start or null
+ get end: -> @_end or null
+ get type: -> @_data.type
+
+ # Methods:
save: (_) ->
try
# TODO: check for actual modification
View
@@ -1,7 +1,7 @@
{
"name": "neo4j",
"description": "Neo4j driver (REST API client) for Node.js",
- "version": "0.2.7",
+ "version": "0.2.8",
"author": "The Thingdom <info@thethingdom.com>",
"contributors": [
{"name": "Daniel Gasienica", "email": "daniel@gasienica.ch"},
@@ -39,6 +39,7 @@
"clean": "cake clean",
"prepublish": "cake build",
"postpublish": "cake clean",
+ "profile": "coffee-streamline test/profile",
"test": "coffee-streamline test"
},
"engines": {
View
@@ -0,0 +1,18 @@
+return if not require('streamline/module')(module)
+
+# this file is in streamline syntax!
+# https://github.com/Sage/streamlinejs
+
+neo4j = require '..'
+db = new neo4j.GraphDatabase 'http://localhost:7474'
+
+NUM_NODES = 100000
+
+console.log "Constructing #{NUM_NODES} nodes..."
+beginTime = Date.now()
+
+for i in [0...NUM_NODES]
+ db.createNode {}
+
+timeDelta = Date.now() - beginTime
+console.log "Took #{timeDelta / 1000} secs."

0 comments on commit 14b109b

Please sign in to comment.