I bought 30 usb at lady's market in HongKong. I thought I was very lucky because they were very chip prices.
But many USBs do not work. Even though copying speed of worked USBs are very slow and one doesn't have no memory chip. (below picture)
Culture, IT, Trend, Travel , Experience korea travel & culture youtube: https://www.youtube.com/@kawadakr
2014. 1. 17.
2014. 1. 13.
Fish street in Hong kong(홍콩물고기 거리)
2014. 1. 10.
Compare running time of String concat methods in python ( only time)
I just describe about concat methods at previous post. Some guy asked me 'just method ?' and I answered 'I will test'.
Only run twice about tree methods. This test show only running time. It does not consider memory usages. Next time I will consider both of them (time and memory).
If you have any advice. comment please.
Thanks.
==Test result. ==
2014-01-10 10:39:56,700 INFO -------------------------------------
2014-01-10 10:39:56,700 DEBUG START(Normal string Plus)
2014-01-10 10:40:06,388 DEBUG END: running time==>9
2014-01-10 10:40:06,390 DEBUG START(StreamWriter)
2014-01-10 10:42:15,395 DEBUG END: running time==>129
2014-01-10 10:42:15,395 DEBUG START(List and Join)
2014-01-10 10:42:27,121 DEBUG END: running time==>11
2014-01-10 10:42:56,802 INFO -------------------------------------
2014-01-10 10:42:56,802 DEBUG START(Normal string Plus)
2014-01-10 10:43:06,098 DEBUG END: running time==>9
2014-01-10 10:43:06,098 DEBUG START(StreamWriter)
2014-01-10 10:45:22,296 DEBUG END: running time==>136
2014-01-10 10:45:22,296 DEBUG START(List and Join)
2014-01-10 10:45:33,914 DEBUG END: running time==>11
== TEST Code ==
import datetime
import time
import sys
import logging
import codecs
import cStringIO, codecs
class StringOperation:
#using +
def run_concat_test_01(self):
for idx in range(1,1000):
src = "{}".format(idx)
for subidx in range(1,10000):
src = src + "AAAAA"
src = src + "BBBBB"
src = src + "BBBBB"
src = src + "CCCCC"
src = src + "한글 " # non romantic
res = src # coppy other
#using writer
def run_concat_test_02(self):
for idx in range(1,1000):
source = cStringIO.StringIO()
wrapper = codecs.getwriter("utf8")(source)
wrapper.writelines("{}".format(idx))
for subidx in range(1,10000):
wrapper.writelines("AAAAA")
wrapper.writelines("BBBBB")
wrapper.writelines("BBBBB")
wrapper.writelines("CCCCC")
wrapper.writelines(u"한글") #non romantic
res = wrapper.getvalue() #copy res
source.close()
# using list + join
def run_concat_test_03(self):
for idx in range(1,1000):
source = []
source.append("{}".format(idx))
for subidx in range(1,10000):
source.append("AAAAA")
source.append("BBBBB")
source.append("BBBBB")
source.append("CCCCC")
source.append(u"한글") #non romantic
res = "".join(source)
def run_test(self, title, func_idx):
funcs={
"plus": self.run_concat_test_01,
"writer": self.run_concat_test_02,
"list":self.run_concat_test_03}
st_time = datetime.datetime.now()
logging.debug("START({})".format(title))
funcs[func_idx]()
ed_time = datetime.datetime.now()
diff_time = ed_time - st_time
logging.debug("END: running time : {} seconds\r\n".format(diff_time.seconds))
today = datetime.date.today()
fname = "{0}{1}{2}-String_operation.log".format(today.year,today.month,today.day)
logging.basicConfig(filename=fname,level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s')
logging.info("-------------------------------------")
oTester = StringOperation()
print "Plus Method"
oTester.run_test("Normal string Plus","plus")
print "Writer Method"
oTester.run_test("StreamWriter", "writer")
print "List Method"
oTester.run_test("List and Join","list")
== Running Environment==
windows 7 64bit
memory : 8G
pythone 2.7.3 (32bit) # I used 32bit for compatibility
Only run twice about tree methods. This test show only running time. It does not consider memory usages. Next time I will consider both of them (time and memory).
If you have any advice. comment please.
Thanks.
==Test result. ==
2014-01-10 10:39:56,700 INFO -------------------------------------
2014-01-10 10:39:56,700 DEBUG START(Normal string Plus)
2014-01-10 10:40:06,388 DEBUG END: running time==>9
2014-01-10 10:40:06,390 DEBUG START(StreamWriter)
2014-01-10 10:42:15,395 DEBUG END: running time==>129
2014-01-10 10:42:15,395 DEBUG START(List and Join)
2014-01-10 10:42:27,121 DEBUG END: running time==>11
2014-01-10 10:42:56,802 INFO -------------------------------------
2014-01-10 10:42:56,802 DEBUG START(Normal string Plus)
2014-01-10 10:43:06,098 DEBUG END: running time==>9
2014-01-10 10:43:06,098 DEBUG START(StreamWriter)
2014-01-10 10:45:22,296 DEBUG END: running time==>136
2014-01-10 10:45:22,296 DEBUG START(List and Join)
2014-01-10 10:45:33,914 DEBUG END: running time==>11
== TEST Code ==
import datetime
import time
import sys
import logging
import codecs
import cStringIO, codecs
class StringOperation:
#using +
def run_concat_test_01(self):
for idx in range(1,1000):
src = "{}".format(idx)
for subidx in range(1,10000):
src = src + "AAAAA"
src = src + "BBBBB"
src = src + "BBBBB"
src = src + "CCCCC"
src = src + "한글 " # non romantic
res = src # coppy other
#using writer
def run_concat_test_02(self):
for idx in range(1,1000):
source = cStringIO.StringIO()
wrapper = codecs.getwriter("utf8")(source)
wrapper.writelines("{}".format(idx))
for subidx in range(1,10000):
wrapper.writelines("AAAAA")
wrapper.writelines("BBBBB")
wrapper.writelines("BBBBB")
wrapper.writelines("CCCCC")
wrapper.writelines(u"한글") #non romantic
res = wrapper.getvalue() #copy res
source.close()
# using list + join
def run_concat_test_03(self):
for idx in range(1,1000):
source = []
source.append("{}".format(idx))
for subidx in range(1,10000):
source.append("AAAAA")
source.append("BBBBB")
source.append("BBBBB")
source.append("CCCCC")
source.append(u"한글") #non romantic
res = "".join(source)
def run_test(self, title, func_idx):
funcs={
"plus": self.run_concat_test_01,
"writer": self.run_concat_test_02,
"list":self.run_concat_test_03}
st_time = datetime.datetime.now()
logging.debug("START({})".format(title))
funcs[func_idx]()
ed_time = datetime.datetime.now()
diff_time = ed_time - st_time
logging.debug("END: running time : {} seconds\r\n".format(diff_time.seconds))
today = datetime.date.today()
fname = "{0}{1}{2}-String_operation.log".format(today.year,today.month,today.day)
logging.basicConfig(filename=fname,level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s')
logging.info("-------------------------------------")
oTester = StringOperation()
print "Plus Method"
oTester.run_test("Normal string Plus","plus")
print "Writer Method"
oTester.run_test("StreamWriter", "writer")
print "List Method"
oTester.run_test("List and Join","list")
== Running Environment==
windows 7 64bit
memory : 8G
pythone 2.7.3 (32bit) # I used 32bit for compatibility
2014. 1. 8.
Python String concat and Charset
I found first method to use for string-concat. but It makes errors for non-romantic characters. So, I use second method by using join.
1) using StringIO
# coding:utf-8
from cStringIO import StringIO
txt = StringIO()
txt.write("AAAAA")
txt.write("BBBBB")
txt.write("?????") # non romantic characters will occur Error~
other_function( txt.getvalue())
txt.close()
2) using join and list
# coding:utf-8
txt = []
txt.append("AAAAA")
txt.append("BBBBB")
txt.append("??????") # non romantic characters will not occur Error.
other_function( "".join(txt))
3) using Stream ## update ( thank you~, Justin )
source = cStringIO.StringIO()
wrapper = codecs.getwriter("utf8")(source)
wrapper.writelines(unicode("AAAA "))
wrapper.writelines(unicode("non romantic => 비 로만틱"))
other_funcion( source.getvalue().decode("utf-8") )
soruce.close()
2014. 1. 6.
대학로 카스테라집 '기적'-'나카사키 카스테라'
우연히 발견한 대학로 카스테라 집~
우연히 식당을 나서다가 발견한 카스테라 집. 이름은 '기적'. 아기자기한 분위기에 이끌려 안으로 들어 갔다.
기념으로 일반,초코 카스테라를 샀다. 옛날 친척누나가 해주던 카스테라가 기억이 난다.
혹시 지나갈 일이 있으면 한번 들러 보세요 .. 요즘은 워낙 인터넷으로 잘 검색되니 검색 해보시길....
p.s.: 나름 유명한 집인가 봐요... ^^;
기념으로 일반,초코 카스테라를 샀다. 옛날 친척누나가 해주던 카스테라가 기억이 난다.
일본에서 배워왔다고 한다. 카스테라 맛은 달고 묵직한 맛.
혹시 지나갈 일이 있으면 한번 들러 보세요 .. 요즘은 워낙 인터넷으로 잘 검색되니 검색 해보시길....
p.s.: 나름 유명한 집인가 봐요... ^^;
피드 구독하기:
글 (Atom)