ASF Bugzilla – Attachment 34054 Details for
Bug 57919
Support in-place write when opened from a File
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
timing saving an HSSFWorkbook on local/network drive and buffered/unbuffered
bug57919.py (text/plain), 1.87 KB, created by
Javen O'Neal
on 2016-07-19 02:57:47 UTC
(
hide
)
Description:
timing saving an HSSFWorkbook on local/network drive and buffered/unbuffered
Filename:
MIME Type:
Creator:
Javen O'Neal
Created:
2016-07-19 02:57:47 UTC
Size:
1.87 KB
patch
obsolete
># Using Jython 2.5.1 and Apache POI 3.11 > >from __future__ import with_statement > >import random >import profile >import marshal > >from java.io import File, FileOutputStream, BufferedOutputStream >from org.apache.poi.ss.usermodel import WorkbookFactory > >filename = '53446.xls' >wb = WorkbookFactory.create(File('C:\\temp\\'+filename)) > >#modify the workbook >wb.createSheet('a new sheet') > >def save_local_unbuffered(wb, filename): > fos = FileOutputStream('C:\\temp\\'+filename) > wb.write(fos) > fos.close() > >def save_local_buffered(wb, filename): > fos = FileOutputStream('C:\\temp\\'+filename) > bos = BufferedOutputStream(fos) > wb.write(bos) > bos.close() > fos.close() > >def save_network_unbuffered(wb, filename): > fos = FileOutputStream('Q:\\temp\\'+filename) > wb.write(fos) > fos.close() > >def save_network_buffered(wb, filename): > fos = FileOutputStream('Q:\\temp\\'+filename) > bos = BufferedOutputStream(fos) > wb.write(bos) > bos.close() > fos.close() > >def main(): > trials = 30 > save_funcs = [save_local_unbuffered, save_local_buffered, save_network_unbuffered, save_network_buffered]*trials > random.shuffle(save_funcs) > for i, save in enumerate(save_funcs): > print('Running %d: %s' % (i, save.__name__)) > save(wb, '%s %d.xls' % (filename, i)) > >pstatsfile = 'C:\\temp\\results.pstats' >profile.run('main()', 'C:\\temp\\results.pstats') > >def pstats2csv(pstatsfile): > with open(pstatsfile, 'r') as p: > k = marshal.loads(p.read()) > with open(pstatsfile+'.csv', 'w') as csv: > csv.write('"ncalls", "tottime", "cumtime", "function", "location"%s' % "\n") > for func, (cc, nc, tt, ct, callers) in k.iteritems(): > csv.write('%d, %f, %f, "%s", "%s:%d", %s' % (nc, tt, ct, func[-1], func[0], func[1], "\n")) > >pstats2csv(pstatsfile)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 57919
:
34054
|
34055
|
34056